non-greedy Questions
4
Solved
How do I tell RegEx (.NET version) to get the smallest valid match instead of the largest?
Cone asked 17/12, 2009 at 7:12
13
Solved
What are these two terms in an understandable way?
Commemorate asked 20/2, 2010 at 6:17
4
This pattern:
/a+?b+?/
Against the following string:
aaaaaabbbbbb
Matches:
aaaaaab
We see that the non-greedy behaves different in backward/left direction (takes all) and forward/right dir...
Pompei asked 3/3, 2013 at 21:47
3
Solved
I need help about regular expression matching with non-greedy option.
The match pattern is:
<img\s.*>
The text to match is:
<html>
<img src="test">
abc
<img
src="a"...
Hamner asked 10/8, 2012 at 9:37
3
Solved
I'm attempting to non-greedily parse out TD tags. I'm starting with something like this:
<TD>stuff<TD align="right">More stuff<TD align="right>Other stuff<TD>things<TD&g...
Package asked 12/12, 2012 at 16:28
3
Solved
I want to remove a pattern with sed, only at second occurence. Here is what I want, remove a pattern but on second occurrence.
What's in the file.csv:
a,Name(null)abc.csv,c,d,Name(null)abc.csv,f
...
Hiro asked 15/9, 2017 at 11:47
3
Solved
I have two type of strings in one text:
a(bc)de(fg)h
a(bcd(ef)g)h
I need to get text between first level parentheses. In my example this is:
bc
fg
bcd(ef)g
I tried to use next re...
Wanting asked 8/4, 2017 at 13:10
5
Solved
Is there a way to use a non-greedy regular expression in C like one can use in Perl?
I tried several things, but it's actually not working.
I'm currently using this regex that matches an IP addres...
Resolutive asked 27/11, 2013 at 10:26
2
Solved
I need to match @anything_here@ from a string @anything_here@dhhhd@shdjhjs@. So I'd used following regex.
^@.*?@
or
^@[^@]*@
Both way it's work but I would like to know which one would be a b...
Vudimir asked 21/12, 2016 at 18:14
3
Solved
I have a string
"{1} {2} {4} {abc} {abs}"
and the regular expression
/\{(.+)\}/g
In PHP regular expressions i can use modifier "U" (U modifier: Ungreedy. The match becomes lazy by def...
Menderes asked 17/4, 2016 at 18:50
3
Solved
I have a very simple regex similar to this:
HOHO.*?_HO_
With this test string...
fiwgu_HOHO_HOHO_HOHOrgh_HOHO_feh_HOHO___HO_fbguyev
I expect it to match just _HOHO___HO_ (shortest match, non-...
Boyes asked 9/12, 2014 at 18:15
2
Solved
I understand the ? mark here means "lazy".
My question essentially is [0-9]{2}? vs [0-9]{2}
Are they same?
If so, why are we writing the former expression? Aren't lazy mode more expensive perform...
Historiated asked 8/9, 2014 at 16:13
2
Solved
I have two sentences as input. Let's say for example:
<span>I love my red car.</span>
<span>I love my car.</span>
Now I want to match every textpart inside the span-tags ...
Newmown asked 18/9, 2013 at 7:16
4
Solved
I have a .net regex which I am testing using Windows Powershell. The output is as follows:
> [System.Text.RegularExpressions.Regex]::Match("aaa aaa bbb", "aaa.*?bbb")
Groups : {aaa aaa bbb}
S...
Tadtada asked 19/5, 2013 at 9:44
2
Solved
I would like to match dotall and non-greedy. This is what I have:
img(.*?)(onmouseover)+?(.*?)a
However, this is not being non-greedy. This data is not matching as I expected:
<img src="icon...
Separates asked 29/2, 2012 at 22:41
2
Solved
I have next code:
public static void createTokens(){
String test = "test is a word word word word big small";
Matcher mtch = Pattern.compile("test is a (\\s*.+?\\s*) word (\\s*.+?\\s*)").matcher...
Allusive asked 19/1, 2012 at 18:16
1
Solved
Suppose I'm writing a rudimentary SQL parser in Scala. I have the following:
class Arith extends RegexParsers {
def selectstatement: Parser[Any] = selectclause ~ fromclause
def selectclause: Par...
Vinavinaceous asked 18/10, 2011 at 19:33
1
Suppose I have a regex language supporting literals, positive and negative character classes, ordered alternation, and the greedy quantifiers ?, *, and +. (This is essentially a subset of PCRE with...
Flagellant asked 20/7, 2011 at 18:15
6
Solved
EDIT: remove original example because it provoked ancillary answers. also fixed the title.
The question is why the presence of the "$" in the regular expression effects the greedyness of the expre...
Furey asked 3/5, 2011 at 23:44
4
Solved
I decided to, for fun, make something similar to markdown. With my small experiences with Regular Expressions in the past, I know how extremely powerful they are, so they will be what I need.
So, ...
Attorn asked 25/10, 2010 at 21:51
3
Solved
How can I get all the matches in the following example:
// Only "abcd" is matched
MatchCollection greedyMatches = Regex.Matches("abcd", @"ab.*");
// Only "ab" is matched
MatchCollection lazyMatch...
Dibromide asked 9/10, 2010 at 22:48
3
Solved
I'm trying to split up a string into two parts using regex. The string is formatted as follows:
text to extract<number>
I've been using (.*?)< and <(.*?)> which work fine but afte...
Second asked 19/6, 2010 at 10:16
3
Solved
I thought that by default my Regex would exhibit the greedy behavior that I want, but it is not in the following code:
Regex keywords = new Regex(@"in|int|into|internal|interface");
var targets ...
Procurable asked 7/3, 2010 at 2:23
4
Solved
Say, I have a line that contains the following string:
"$tom" said blah blah blash. "$dick" said "blah blah blah". "$harry" said blah blah blah.
and I want to extract
"$dick" said "blah blah...
Rogerrogerio asked 21/10, 2009 at 5:52
6
Solved
I have always written regexes like this
<A HREF="([^"]*)" TARGET="_blank">([^<]*)</A>
but I just learned about this lazy thing and that I can write it like this
<A HREF="(.*?)...
Troytroyer asked 14/12, 2008 at 18:36
1 Next >
© 2022 - 2024 — McMap. All rights reserved.