Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post |
Boom.dk Posts: 18/356 |
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. |
MathOnNapkins Posts: 65/1106 |
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 Posts: 17/356 |
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 Posts: 59/1106 |
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 Posts: 15/356 |
What does "quantifier minimizer" (the ? ) mean? What does it do? |