|
.* will match everything in a greedy manner .*? will match everything in a non-greedy manner. That means that the first one may take out more than you want, or the second one may not take out as much as you want depending on the situation e.g. <cfsavecontent variable="str"> <cfoutput> <table> <tr> <td>Some Text</td> </tr> </table> <br> <br> </cfoutput> </cfsavecontent> <cfset innerString1 = reReplaceNoCase(str,'(<t[^>]*>)(.*)(</t[^>]*>)','\2','all')> <cfset innerString2 = reReplaceNoCase(str,'(<t[^>]*>)(.*?)(</t[^>]*>)','\2','all')> <cfoutput> GREEDY: #HTMLCodeFormat(innerString1)# NON GREEDY: #HTMLCodeFormat(innerString2)# </cfoutput> In your case it doesn't make any difference. I just tend to make regexes non-greedy unless I specifically want them to be greedy. I find it makes it easier to build complex expressions that way. Spike Mark M wrote:
-- Stephen Milligan Consultant for hire http://www.spike.org.uk--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/ |
- [cfaussie] Re: OT: RegEx: Gimme the <h1> Spike
- [cfaussie] Re: OT: RegEx: Gimme the <h1> Mark M
- Spike
