(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-29-24 07:00 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - PCRE New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Boom.dk









Since: 11-18-05
From: Denmark

Last post: 6327 days
Last view: 6309 days
Skype
Posted on 12-10-05 04:01 AM Link | Quote
What does "quantifier minimizer" (the ? ) mean? What does it do?
MathOnNapkins

1100

In SPC700 HELL


 





Since: 11-18-05

Last post: 6309 days
Last view: 6309 days
Posted on 12-10-05 05:57 AM Link | Quote
It picks up 0 or 1 occurences of a particular group.

So if you had the regex: "(3?)(5)(4+)"

It would pick up: "35444......" or "5444....." where .... indicates infinitely many 4's.

Thus it means the 3 is optional but if it does see it it makes sure to grab it.

? is shorthand for {0,1} (zero to one occurences). You can use curly braces for abitrary bounds, like {5,7} (five to seven occurences)

I myself needed a small refresher so this is where I made sure I knew what I was talking about: http://www.tote-taste.de/X-Project/regex/syntax.html
Boom.dk









Since: 11-18-05
From: Denmark

Last post: 6327 days
Last view: 6309 days
Skype
Posted on 12-10-05 08:59 AM Link | Quote
Ok thanks but I figured it out. The thing with the quantifier minimizer, that is.

If you had like... a string... umm like... "yes! this is a string" then "t.*s" would prolly eat "this is a s" while "t.*?s" would only eat "this".

...I think. Lol.
MathOnNapkins

1100

In SPC700 HELL


 





Since: 11-18-05

Last post: 6309 days
Last view: 6309 days
Posted on 12-10-05 09:18 AM Link | Quote
I'm not even sure if that would work given you have two special symbols together. i.e., the *? combination. I can't remember if you can do that but I seem to recall some special combinations, however this link says otherwise. http://www.opengroup.org/onlinepubs/007908799/xbd/re.html

The behaviour of multiple adjacent duplication symbols (+, *, ? and intervals) produces undefined results.

So in conclusion either my memory is making stuff up, or what is valid depends on the library of regular expression software you are using. I've seen it vary from Python to Perl, to Microsoft, to Java. Actual treatment of symbols seems fairly uniform but sometimes has glaring differences.
Boom.dk









Since: 11-18-05
From: Denmark

Last post: 6327 days
Last view: 6309 days
Skype
Posted on 12-10-05 10:55 AM Link | Quote
Umm... I'm using it in PHP...

? - extends the meaning of (, also 0 or 1 quantifier, also quantifier minimizer

Since * is a quantifier, ? probably minimizes it (making it un-greedy)... or something like that.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - PCRE |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.026 seconds; used 368.72 kB (max 439.84 kB)