[Solved] tokenizing and parsing with python

To retrieve the data from the file.txt: data = {} with open(‘file.txt’, ‘r’) as f: # opens the file for line in f: # reads line by line key, value = line.split(‘ : ‘) # retrieves the key and the value data[key.lower()] = value.rstrip() # key to lower case and removes end-of-line ‘\n’ Then, data[‘name’] … Read more

[Solved] Parsing custom string

Very simple Use the str.split() function transform your alphabet soup, then split the single elements further by directly accessing them. For example: text=””‘ A1 A10 A10 B14 C1 C14 C14 C8 ”’ for t in text.split(): print( {t[0]: t[1:]} ) prints: {‘A’: ‘1’} {‘A’: ’10’} {‘A’: ’10’} {‘B’: ’14’} {‘C’: ‘1’} {‘C’: ’14’} {‘C’: ’14’} … Read more

[Solved] Parse INI in Perl (list format)

You haven’t told us the expected format for the data or shown any existing code, so it’s impossible to know what you’re looking for, but this should get you at least 90% of the way there: use strict; use warnings; use Data::Dumper; my %config; my $group = ”; while (<DATA>) { chomp; next unless /\S/; … Read more

[Solved] Multiple array json parsing under a object in android [closed]

Use from this link and in doInBackground method you must have these code: if (jsonStr != null) { try { JSONObject jsonObj = new JSONObject(jsonStr); JSONObject data = jsonObj.getJSONObject(“data”); // Getting JSON Array node JSONArray ambulance = jsonObj.getJSONArray(“ambulance”); // looping through All ambulance for (int i = 0; i < ambulance.length(); i++) { JSONObject c … Read more

[Solved] Show JSON in tableview IOS Xcode [closed]

try this convert the response json into NSDictionary NSDictionary *receivedDataDic = [NSJSONSerialization JSONObjectWithData:operation.responseObject options:kNilOptions error:&error]; now access the values which you want by using key names , like NSString * id = [receivedDataDic valueForKey:@”id”]; NSString * name = [receivedDataDic valueForKey:@”name”]; use those variables where you want make these changes in your code @interface ViewController () … Read more

[Solved] How to make PHP BB Codes with RegExp?

The user asked for something simple, so I gave him something simple. $input = “[link=http://www.google.com]test[/link]”; $replacement = preg_replace(‘/\[link=(.*?)\](.*?)\[\/link\]/’, ‘<a href=”https://stackoverflow.com/questions/10458103/”>$2</a>’, $input); Where /\[link=(.*?)\](.*?)\[\/link\]/ is the regex, <a href=”https://stackoverflow.com/questions/10458103/”>$2</a> is the format, $input is the input/data, and $replacement is the return. 1 solved How to make PHP BB Codes with RegExp?