Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
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: 6442 days Last view: 6424 days |
| ||
What does "quantifier minimizer" (the ? ) mean? What does it do? | |||
MathOnNapkins 1100 In SPC700 HELL Since: 11-18-05 Last post: 6424 days Last view: 6424 days |
| ||
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: 6442 days Last view: 6424 days |
| ||
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: 6424 days Last view: 6424 days |
| ||
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 exp |
|||
Boom.dk Since: 11-18-05 From: Denmark Last post: 6442 days Last view: 6424 days |
| ||
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 | | |