regex

re in list of lists

让人想犯罪 __ 提交于 2021-01-29 08:49:25
问题 I have a list of lists (irregular lengths of sub-lists), on which I want to perform re operations but can't get it to work. I'm sure I'm missing something profane; could someone point out what I'm doing wrong? Consider the following code snippets: test_list = [ # sample list of lists in which I want to replace the "\n" ["test\n\n\n\n\n\n\n\n", "another test\n", "spam"], ["egg\n\n", "house"], ["\n\nabc", "def\n", "\n\n\nghi", "jklm\n\n", "nop(e)", "\nqrst\n"], ["uvw\n", "\n\nx", "yz\n\n"]] for

wpf richtextbox selection with regex

你离开我真会死。 提交于 2021-01-29 08:37:39
问题 i want to color the matched text of a file. first,i load the file text into FileItem.Content ,then use regex to get the matches,and next put the Content into a richtextbox and use the matches to set the caret position and color the text . and the code to fill richtextbox RtbCodes.Document.Blocks.Clear(); RtbCodes.Document.Blocks.Add(new Paragraph(new Run(item.Content))); foreach (Match m in item.Matches) { TextPointer start1 = RtbCodes.Document.ContentStart.GetPositionAtOffset(m.Index,

Javascript Regex to allow only 2 digit numbers and 3 digit numbers as comma separated

大憨熊 提交于 2021-01-29 08:30:36
问题 I want Regex for Javascript for below validation: Textbox should allow only 2 digit numbers and 3 digit numbers as comma separated. Ex: 12,123,56,567,789,11 回答1: Hey welcome to Stackoverflow, try this one ([0-9]{1,3},)* - last two or three digit should be without comma (\d{1,3},)*$ - last two or three digit should have comma (\d{2,3}),? - captures both case - wether last two digit have comma or not You can test regular expressions online in this website - make sure the javascript is selected

Regex to extract version from string

痞子三分冷 提交于 2021-01-29 08:20:48
问题 I have a string which has below value String1=winos-app-1.2.0-4.20120308.InLinuxOS.x86_64 I need to extract only version from this string which is "1.2.0-4" I have tried regular expression as mentioned below with sed sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,1\}[0-9][^.]\).*/\1/p' but I am only getting result "1.2.0-", missing number after "-" which is 4. I tried correcting it but it is returning null. Kindly, advise 回答1: how about grep: grep -Po "(?<=-)[\d.-]*(?=.\d{8})" 回答2: This should work, and

How can I count the amount of lines of an HTML code with PHP?

本小妞迷上赌 提交于 2021-01-29 08:13:38
问题 I have some HTML generated by a WYSIWYG-editor (WordPress). I'd like to show a preview of this HTML, by only showing up to 3 lines of text (in HTML format). Example HTML: (always formated with new lines) <p>Hello, this is some generated HTML.</p> <ol> <li>Some list item<li> <li>Some list item</li> <li>Some list item</li> </ol> I'd like to preview a maximum of 4 lines of text in this formated HTML. Example preview to display: (numbers represent line numbers, not actual output). Hello, this is

python regex: create dictionary from string

穿精又带淫゛_ 提交于 2021-01-29 07:54:34
问题 I have a sting containing multiple informations which I want to save in a dictionary: s1 = "10:12:01 R1 3 E44" s2 = "11:11:01 R100 E400" pattern = "\d{2}:\d{2}:\d{2}(\,\d+)?" + \ " +" + \ "[0-9A-Za-z _]{2}([0-9A-Za-z _]{1})?([0-9A-Za-z _]{1})?" + \ " +" + \ "[0-9A-Za-z _]{2}([0-9A-Za-z _]{1})?([0-9A-Za-z _]{1})?$" # --> d1 = {"time" : "10:12:01", "id1" : "R1 3", "id2" : "E44"} d2 = {"time" : "11:11:01", "id1" : "R100", "id2" : "E400"} is there a way doing this directly with python re? Note: I

Regex to match the relative path of the URL

大兔子大兔子 提交于 2021-01-29 07:37:42
问题 How to write the regex that all three situations below matches? The path, file, and query string has to be exact. The domain part could be any variants of the following (domain name/IP address) http://www.example.com/path1/path2/foobar.aspx?id=123&key=456 https://www.example.com/path1/path2/foobar.aspx?id=123&key=456 64.123.456.789/path1/path2/foobar.aspx?id=123&key=456 Basically, only the /path1/path2/foobar.aspx?id=123&key=456 needs to be matched. The part in front of it could be any of the

Regex expression for file name with 2 underscores and 3 segments

和自甴很熟 提交于 2021-01-29 07:30:57
问题 I need a regex expression that will select files with particular file name format from the file list of properties files. I need to select files with file names with following file format: <app_name>_<app_version>_<environment>.properties here <app_name> can be any alphanumeric with special character <A-Z/a-z/0-9/special char> like abc123 or app1-1 here <app_version> can be any alphanumeric with special character <A-Z/a-z/0-9/special char/float value> like abc or even float/integer/string 1.0

Bulk Email Extractor. Need to add a Regxp - excel VBA

安稳与你 提交于 2021-01-29 07:21:23
问题 I am trying to update my first code with parts of a second code, but have been struggling for a few weeks now. Both codes extract emails from a url list. THE FIRST CODE This code is fine apart from it uses Mailto: rather than a Regxp . I am trying to replace the Mailto: in the first code with a Regxp from the second code as the regxp extracts more emails. How the First code works. A list of urls are placed in Sheet2 "Urls" and the results are show in Sheet1 "Results" . This code will extract

Query fields in Kibana with RegEx

Deadly 提交于 2021-01-29 07:08:29
问题 I need to search in Kibana Logs for fields with a specific content. The field is "message", that looks like this: 11.111.72.58 - - [26/Nov/2020:08:44:23 +0000] "GET /images/image.jpg HTTP/1.1" 200 123456 "https://website.com/questionnaire/uuid/result" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.14 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.14" "5.158.163.231" This field contains URIs, for example here "https://website.com/questionnaire/uuid/result". How can I