string-parsing

Perl/regex to remove first 3 lines and last 3 lines of a string

允我心安 提交于 2020-01-01 09:56:08
问题 I was looking to build a regex statement to always remove the first 3 lines of the string, and last 3 lines of the string (the middle part could be any n number of lines content). Any clean regex way to acheive this output? (i.e. always strip our first 3 lines and last 3 lines of the string - and preserve the middle part, which could be a variable # of lines) Thanks. e.g. Input String: " 1 2 3 <1...n # of lines content> 4 5 6 " To desired output string: "<1..n # of lines content>" 回答1: The

Does OCaml have String.split function like Python?

最后都变了- 提交于 2019-12-30 08:51:49
问题 I am using this to split strings: let split = Str.split (Str.regexp_string " ") in let tokens = split instr in .... But the problem is that for example here is a sentence I want to parse: pop esi and after the split it turns to be (I use a helper function to print each item in the tokens list): item: popitem: item: item: item: esi See, there are three spaces in the token list. I am wondering if there is a string.split like in Python which can parse instr this way: item: popitem: esi Is it

if IP address exist in URL return something else return something

╄→尐↘猪︶ㄣ 提交于 2019-12-25 12:08:36
问题 How do I check whether the IP address exist in URL by using Matlab? Is there any function that can be used to check the IP address? data =['http://95.154.196.187/broser/6716804bc5a91f707a34479012dad47c/', 'http://95.154.196.187/broser/', 'http://paypal.com.cgi-bin-websc5.b4d80a13c0a2116480.ee0r-cmd-login-submit-dispatch-'] def IP_exist(data): for b in data: containsdigit = any(a.isdigit() for a in b) if containsdigit: print("1") else: print("0") 回答1: With regexp , you can either use 'tokens'

Scanner Class InputMismatchException and Warnings

江枫思渺然 提交于 2019-12-25 03:47:25
问题 I am having trouble running this program. The program takes an expression such as "A = 7" and puts the variable A (String) and the number 7 in a Map container. I'm not if i'm not parsing the string correctly which is causing the error or for some other reason. Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:909) at java.util.Scanner.next(Scanner.java:1530) at java.util.Scanner.nextInt(Scanner.java:2160) at java.util.Scanner.nextInt

How to select the first letter of each word from a table cell in MySQL?

穿精又带淫゛_ 提交于 2019-12-24 15:00:40
问题 How can I select the first letter of each word in MySQL using a query? So this table +----+----------------------------+ | id | str | +----+----------------------------+ | 1 | Hello my name is MCEmperor | | 2 | How are you doing? | +----+----------------------------+ would return +----+----------------------------+ | id | str | +----+----------------------------+ | 1 | HmniM | | 2 | Hayd | +----+----------------------------+ I guess it's something with SUBSTRING and LOCATE and maybe I need a

Finding and adding to a .kml file using python

放肆的年华 提交于 2019-12-24 12:18:34
问题 I am not a very good coder. But I really want to automate something I have to do at work. Basically, I have a bunch of placemarkers in google earth showing hand-holes of a municipal fiber network. I have a few pictures of each hand-hole that I want to place as a tag in the .kml file. Basically, I want to have it so when they click on a placemarker in google earth, it brings up the little description bubble and shows the pictures for each hand-hole and probably some other vital info. Right now

php - preg_split() with multiple patterns not splitting quoted string

喜夏-厌秋 提交于 2019-12-24 08:08:23
问题 I need to split a paragraph into sentences. That's where i got a bit confused with the regex. I have already referred this question to which this Q is marked as a duplicate to. but the issue here is different. Here is a example of the string i need to split : hello! how are you? how is life live life, live free. "isnt it?" here is the code i tried : $sentence_array = preg_split('/([.!?\r\n|\r|\n])+(?![^"]*")/', $paragraph, -1); What i need is : array ( [0] => "hello" [1] => "how are you" [2]

Having trouble converting string (parsed from JSON) into javascript date object

烂漫一生 提交于 2019-12-24 03:09:07
问题 I am trying to create javasscript date object in the following way var object = {"name":"Bay Area Global Health Film Festival","start_time":"2013-07-08T19:00:00","end_time":"2013-07-08T23:45:00","timezone":"America/Los_Angeles","location":"San Francisco","id":"458415670892007","rsvp_status":"attending"} var tempDate = date(object.start_time); And I'm getting back the error: date is not defined I have also tried trimming the string using: var tempDate = date(object.start_time.slice(0,object

Python parse string containing functions, lists and dicts

点点圈 提交于 2019-12-24 02:08:08
问题 I'm trying to find way to parse string that can contain variable, function, list, or dict written in python syntax separated with ",". Whitespace should be usable anywhere, so split with "," when its not inside (), [] or {}. Example string: "variable, function1(1,3), function2([1,3],2), ['list_item_1','list_item_2'],{'dict_key_1': "dict_item_1"}" Another example string: "variable,function1(1, 3) , function2( [1,3],2), ['list_item_1','list_item_2'],{'dict_key_1': "dict_item_1"}" Example output

Extract data between two delimiters

走远了吗. 提交于 2019-12-22 13:56:34
问题 I just want to know whether it is possible to pick up the data that is present between two delimiters (delimiter being a string). For example the original string is as under <message%20type%3D"info"%20code%3D"20005">%20<text>Conference%20successfully%20modified</text>%20<data>0117246</data>%20%20</message>%20 and I want the data that is present between <text> tags. The string from which i need the data can be different. The string can also be like this <message%20type%3D"info"%20code%3D"20001