Possessive quantifiers

View: New views
3 Messages — Rating Filter:   Alert me  

Possessive quantifiers

by Michael Dinowitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just found out about possessive quantifiers from the O'Reilly Regular Expression pocket reference. Something not mentioned in most places and after some tests does not seem to be part of the CF RegEx ability. This code:
<cfset test=refindnocase('(ab)++', 'abababababababab',1,1)>
<cfdump var="#test#">

returns this error:
Malformed regular expression "(ab)++".  
Reason: Nested repetitions *?+ in expression.  

Not really important, but interesting none the less.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:875
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Possessive quantifiers

by Massimo Foti-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They don't work in CFML, but they do just fine using the RegExp library in
JRE 1.4.
You can try them out using this CFC:
http://www.massimocorner.com/coldfusion/cfc/tmt_java_regexp.zip

Then run something likethis:
<cfset regExpObj=CreateObject("component","tmt_java_regexp")>
<cfdump var="#regExpObj.regExpMatches("(ab)+?", "abababababababab", 1)#"
label='regExpMatches("(ab)+?", "abababababababab", 1)'>
<cfdump var="#regExpObj.regExpMatches("(ab)++", "abababababababab", 1)#"
label='regExpMatches("(ab)++", "abababababababab", 1)'>

----------------------------
Massimo Foti
Tools for ColdFusion and Dreamweaver developers:
http://www.massimocorner.com
----------------------------



> Just found out about possessive quantifiers from the O'Reilly Regular
Expression pocket reference. Something not mentioned in most places and
after some tests does not seem to be part of the CF RegEx ability. This
code:
> <cfset test=refindnocase('(ab)++', 'abababababababab',1,1)>
> <cfdump var="#test#">
>
> returns this error:
> Malformed regular expression "(ab)++".
> Reason: Nested repetitions *?+ in expression.
>
> Not really important, but interesting none the less.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
 Save $10 Download ZoneAlarm Security Suite
http://www.houseoffusion.com/banners/view.cfm?bannerid=66

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:876
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Possessive quantifiers

by Michael Dinowitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's what I love about CF. If the base language can't do it you can always
dig a bit deeper. :)

> They don't work in CFML, but they do just fine using the RegExp library in
> JRE 1.4.
> You can try them out using this CFC:
> http://www.massimocorner.com/coldfusion/cfc/tmt_java_regexp.zip
>
> Then run something likethis:
> <cfset regExpObj=CreateObject("component","tmt_java_regexp")>
> <cfdump var="#regExpObj.regExpMatches("(ab)+?", "abababababababab", 1)#"
> label='regExpMatches("(ab)+?", "abababababababab", 1)'>
> <cfdump var="#regExpObj.regExpMatches("(ab)++", "abababababababab", 1)#"
> label='regExpMatches("(ab)++", "abababababababab", 1)'>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase Studio MX from House of Fusion, a Macromedia Authorized Affiliate and support the CF community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=50

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:877
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54