regex-greedy

Multiline python regex

梦想的初衷 提交于 2020-05-14 19:09:39
问题 I have a file structured like this : A: some text B: more text even more text on several lines A: and we start again B: more text more multiline text I'm trying to find the regex that will split my file like this : >>>re.findall(regex,f.read()) [('some text','more text','even more text\non several lines'), ('and we start again','more text', 'more\nmultiline text')] So far, I've ended up with the following : >>>re.findall('A:(.*?)\nB:(.*?)\n(.*?)',f.read(),re.DOTALL) [(' some text', ' more

Multiline python regex

心已入冬 提交于 2020-05-14 19:09:23
问题 I have a file structured like this : A: some text B: more text even more text on several lines A: and we start again B: more text more multiline text I'm trying to find the regex that will split my file like this : >>>re.findall(regex,f.read()) [('some text','more text','even more text\non several lines'), ('and we start again','more text', 'more\nmultiline text')] So far, I've ended up with the following : >>>re.findall('A:(.*?)\nB:(.*?)\n(.*?)',f.read(),re.DOTALL) [(' some text', ' more

Multiline python regex

我只是一个虾纸丫 提交于 2020-05-14 19:09:21
问题 I have a file structured like this : A: some text B: more text even more text on several lines A: and we start again B: more text more multiline text I'm trying to find the regex that will split my file like this : >>>re.findall(regex,f.read()) [('some text','more text','even more text\non several lines'), ('and we start again','more text', 'more\nmultiline text')] So far, I've ended up with the following : >>>re.findall('A:(.*?)\nB:(.*?)\n(.*?)',f.read(),re.DOTALL) [(' some text', ' more

Regex for getting all digits in a string after a character

倖福魔咒の 提交于 2020-02-15 08:01:07
问题 I am trying to parse the following string and return all digits after the last square bracket: C9: Title of object (foo, bar) [ch1, CH12,c03,4] So the result should be: 1,12,03,4 The string and digits will change. The important thing is to get the digits after the '[' regardless of what character (if any) precede it. (I need this in python so no atomic groups either!) I have tried everything I can think of including: \[.*?(\d) = matches '1' only \[.*(\d) = matches '4' only \[*?(\d) = matches

Regex for getting all digits in a string after a character

北城余情 提交于 2020-02-15 08:00:29
问题 I am trying to parse the following string and return all digits after the last square bracket: C9: Title of object (foo, bar) [ch1, CH12,c03,4] So the result should be: 1,12,03,4 The string and digits will change. The important thing is to get the digits after the '[' regardless of what character (if any) precede it. (I need this in python so no atomic groups either!) I have tried everything I can think of including: \[.*?(\d) = matches '1' only \[.*(\d) = matches '4' only \[*?(\d) = matches

Regex to catch these patterns recursively

有些话、适合烂在心里 提交于 2020-01-25 20:15:06
问题 java.util.regex.Pattern ips = java.util.regex.Pattern.compile("(\\d{1,3}(?:\\.\\d{1,3}){2}\\.(\\d{1,3}))(?:(?:-|\\s+to\\s+)(\\d{1,3}(?![\\d\\.]))|(?:-|\\s*to\\s+)(\\d{1,3}(?:\\.\\d{1,3}){3})|\\s+(25\\d(?:\\.\\d{1,3}){3})|\\s*\\/(\\d{1,3}))?"); Currently my Regex will accept the following types of IP address input, but only one input type at a time: ip: "47.1.2.3" range: "47.1.2.3-4" ip range: "47.1.2.3-47.1.2.4" ip to range: "47.1.2.3 to 4" ip to ip range: "47.1.2.3 to 47.1.2.4" ip CIDR: "47

regex to grab text if code exists

假如想象 提交于 2020-01-24 12:02:40
问题 I m trying to build a regex to add the code value if codename exists say an example: {(en56), (sc45), (da77), (cd29)} {(en56), (sc45), (cd29)} i will write a regex like {[(]en(?<en>\d{2}).*[(]sc(?<sc>\d{2}).*[(]da(?<da>\d{2}).*[(]cd(?<cd>\d{2}).* i will grab the first line anyway as it matches and the results of marks will be extracted. how to keep da as optional if the input comes without it. when i tried with ? , it basically eliminates the values from first result {[(]en(?<en>\d{2}).*[(]sc

regex to grab text if code exists

醉酒当歌 提交于 2020-01-24 12:02:07
问题 I m trying to build a regex to add the code value if codename exists say an example: {(en56), (sc45), (da77), (cd29)} {(en56), (sc45), (cd29)} i will write a regex like {[(]en(?<en>\d{2}).*[(]sc(?<sc>\d{2}).*[(]da(?<da>\d{2}).*[(]cd(?<cd>\d{2}).* i will grab the first line anyway as it matches and the results of marks will be extracted. how to keep da as optional if the input comes without it. when i tried with ? , it basically eliminates the values from first result {[(]en(?<en>\d{2}).*[(]sc

How to parse data using REGEXP_SUBSTR?

自作多情 提交于 2020-01-22 02:16:46
问题 I have a data set like this (see below) and I try to extract digits which are in form {variable_number_of_digits}{hyphen}{only_one_digit}: with mcte as ( select 'ILLD/ELKJS/00000000/ELKJS/FHSH' as addr from dual union all select 'ILLD/EFECTE/0116988-7-002/ADFA/ADFG' as addr from dual union all select 'IIODK/1573230-0/2216755-7/' as addr from dual union all select 'IIODK/1573230-0/2216755-700/WRITE' as addr from dual ) select addr, REGEXP_SUBSTR(addr,'(\/)([0-9-]+)',1,1,NULL,2) AS num1, REGEXP

Truncate trailing zeroes regex

a 夏天 提交于 2020-01-15 10:53:28
问题 How to get a match using regex to truncate zeroes in a string like this 45.9390 => 45.939 32.00 => 32.0 [Need this for my use case] 32.0050 => 32.005 32 => 32 I am using Java. I am just looking for the regex. This is my closest attempt( https://regex101.com/r/mD7gK4/79 ). I am missing on the second case. 回答1: I have edited your regex: ^([+-]?\d*\.0)0+$|^([+-]?\d*\.?\d*?)0*$ and use \1\2 as substitution string: Demo : https://regex101.com/r/mD7gK4/81 Output : 45.9390 => 45.939 32.00 => 32.0 32