Re: regular expressions
i have some html files which i need to be able to read and find all referenced files in it. Like all jpg, gif, css, js files etc that are being used inside the html tags. This is a job for CF_REExtract! See: http://www.contentbox.com/claude/customtags/REextract/testREextract.cfm -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295503 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
On Dec 28, 2007 2:11 PM, Claude Schneegans [EMAIL PROTECTED] wrote: i have some html files which i need to be able to read and find all referenced files in it. Like all jpg, gif, css, js files etc that are being used inside the html tags. This is a job for CF_REExtract! See: http://www.contentbox.com/claude/customtags/REextract/testREextract.cfm yeah, didn't see that coming :) -- Scientists tell us that the fastest animal on earth, with a top speed of 120 feet per second, is a cow that has been dropped out of a helicopter. - Dave Barry ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295504 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: regular expressions
yeah, didn't see that coming LOL... always ready to help people -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295507 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: regular expressions
thanks guys any other ideas, code samples etc? On Dec 28, 2007 6:13 PM, Claude Schneegans [EMAIL PROTECTED] wrote: yeah, didn't see that coming LOL... always ready to help people -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295508 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
any other ideas Don't ask me ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295509 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: regular expressions
I know some regex people are going to jump all over this but I really don't know regex.. Try this on 8 with a html page in the same directory, It will give you an array of structures with information about the images in a html document. html head titleRegEx PlayGround/title /head body !--- read the html file --- cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img[^]*/, htmldoc) cfset files = arrayNew(1) cfloop array=#images# index=i cfset imgpath = REMatchNoCase(.*, i) cfset imgpath = replace(imgpath[1],,,all) cfset tmp = structNew() cfset tmp.path = imgpath cfset tmp.filename = listLast(imgpath,/) cfset tmp.fileExtension = right(imgpath,3) cfset tmp.filetype = image cfset arrayAppend(files,tmp) /cfloop cfdump var=#files# /body /html On Dec 28, 2007 6:33 PM, Claude Schneegans [EMAIL PROTECTED] wrote: any other ideas Don't ask me ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295510 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
Thanks Dan... i tried your code... all i getting in the cfdump is an empty array. Any ideas? On Dec 28, 2007 11:32 PM, Dan Vega [EMAIL PROTECTED] wrote: I know some regex people are going to jump all over this but I really don't know regex.. Try this on 8 with a html page in the same directory, It will give you an array of structures with information about the images in a html document. html head titleRegEx PlayGround/title /head body !--- read the html file --- cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img[^]*/, htmldoc) cfset files = arrayNew(1) cfloop array=#images# index=i cfset imgpath = REMatchNoCase(.*, i) cfset imgpath = replace(imgpath[1],,,all) cfset tmp = structNew() cfset tmp.path = imgpath cfset tmp.filename = listLast(imgpath,/) cfset tmp.fileExtension = right(imgpath,3) cfset tmp.filetype = image cfset arrayAppend(files,tmp) /cfloop cfdump var=#files# /body /html On Dec 28, 2007 6:33 PM, Claude Schneegans [EMAIL PROTECTED] wrote: any other ideas Don't ask me ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295511 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
Dan, I just did a cfdump for variable images in your code. Even that shows up an empty array... are you sure the regular expression is correct in this line? cfset images = REMatchNoCase(img[^]*/, htmldoc) On Dec 28, 2007 11:32 PM, Dan Vega [EMAIL PROTECTED] wrote: I know some regex people are going to jump all over this but I really don't know regex.. Try this on 8 with a html page in the same directory, It will give you an array of structures with information about the images in a html document. html head titleRegEx PlayGround/title /head body !--- read the html file --- cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img[^]*/, htmldoc) cfset files = arrayNew(1) cfloop array=#images# index=i cfset imgpath = REMatchNoCase(.*, i) cfset imgpath = replace(imgpath[1],,,all) cfset tmp = structNew() cfset tmp.path = imgpath cfset tmp.filename = listLast(imgpath,/) cfset tmp.fileExtension = right(imgpath,3) cfset tmp.filetype = image cfset arrayAppend(files,tmp) /cfloop cfdump var=#files# /body /html On Dec 28, 2007 6:33 PM, Claude Schneegans [EMAIL PROTECTED] wrote: any other ideas Don't ask me ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295512 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
Yes. I am reading a html file. I changed the first regular expression like this: cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img([^]*[^/]), htmldoc) This gives me a cfdump of all img tags. but the next few lines are doing something that results in an empty array at the end. But now I am getting a CF error: The element at position 1 of dimension 1, of array variable IMGPATH, cannot be found. The error occurred in C:\regexp.cfm: line 17 15 : cfloop array=#images# index=i 16 : cfset imgpath = REMatchNoCase(.*, i) 17 : cfset imgpath = replace(imgpath[1],,,all) 18 : cfset tmp = structNew() 19 : cfset tmp.path = imgpath ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295513 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: regular expressions
yes. i am sure about that. I have CF8. I think i found out what the problem is. Some of the img tags have no double quotes in them... like this.. img src=/img/jjj.gif instead of img src=/img/jjj.gif On Dec 29, 2007 1:08 AM, Dan Vega [EMAIL PROTECTED] wrote: are you sure your on CF8? REMatchNoCase is a cf8 function? On Dec 29, 2007 12:53 AM, Web Exp [EMAIL PROTECTED] wrote: Yes. I am reading a html file. I changed the first regular expression like this: cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img([^]*[^/]), htmldoc) This gives me a cfdump of all img tags. but the next few lines are doing something that results in an empty array at the end. But now I am getting a CF error: The element at position 1 of dimension 1, of array variable IMGPATH, cannot be found. The error occurred in C:\regexp.cfm: line 17 15 : cfloop array=#images# index=i 16 : cfset imgpath = REMatchNoCase(.*, i) 17 : cfset imgpath = replace(imgpath[1],,,all) 18 : cfset tmp = structNew() 19 : cfset tmp.path = imgpath -- Thank You Dan Vega [EMAIL PROTECTED] http://www.danvega.org ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295514 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: regular expressions
Dan... i also need to do the same thing in CF 7... do you know a quick way to do that too? On Dec 29, 2007 1:11 AM, Web Exp [EMAIL PROTECTED] wrote: yes. i am sure about that. I have CF8. I think i found out what the problem is. Some of the img tags have no double quotes in them... like this.. img src=/img/jjj.gif instead of img src=/img/jjj.gif On Dec 29, 2007 1:08 AM, Dan Vega [EMAIL PROTECTED] wrote: are you sure your on CF8? REMatchNoCase is a cf8 function? On Dec 29, 2007 12:53 AM, Web Exp [EMAIL PROTECTED] wrote: Yes. I am reading a html file. I changed the first regular expression like this: cffile action=read file=#expandPath('homepage.html')# variable=htmldoc !--- return an array of image tags --- cfset images = REMatchNoCase(img([^]*[^/]), htmldoc) This gives me a cfdump of all img tags. but the next few lines are doing something that results in an empty array at the end. But now I am getting a CF error: The element at position 1 of dimension 1, of array variable IMGPATH, cannot be found. The error occurred in C:\regexp.cfm: line 17 15 : cfloop array=#images# index=i 16 : cfset imgpath = REMatchNoCase(.*, i) 17 : cfset imgpath = replace(imgpath[1],,,all) 18 : cfset tmp = structNew() 19 : cfset tmp.path = imgpath -- Thank You Dan Vega [EMAIL PROTECTED] http://www.danvega.org ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295515 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Regular expressions and bluedragon?
Doug Hyde wrote: So, I tried creating a regular expression to remove it and came up with the following: cfset location = ReplaceNoCase(location,[:punct:]?lang=[0-9], , ALL) You need REReplace(), not Replace(). Jochem ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255880 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Regular Expressions - Strip HTML tags. Please help!!!
Thank you guys for pointing me to the right direction. The udf StripTags is really god sent. Thanks cfcoder CFLib.org is your friend :) Check out the function called StripTags. It does exactly what you want. http://www.cflib.org/udf.cfm?ID=774 Cedric ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:238004 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Regular Expressions - Strip HTML tags. Please help!!!
You may have to use a negative lookahead. Try something like this: (?!\/?(br|b|span|i|strong|div|p))[^]* This hasn't been tested and is purely from memory, but I think that (or something close to it) should remove any tag that is *NOT* the open or closing tag of one you listed. For more information on negative lookaheads you can look at the livedocs or google 'regex negative lookahead'. hth. On 4/13/06, cf coder [EMAIL PROTECTED] wrote: Hello Everybody, I need your help with regular expressions. I'm trying to strip out HTML tags from a string to pass it to a flash movie. I've found a script that does this but the problem is that I want to keep some html formatting specifically the following tags: b, br, span, i, strong, div, p Here is the code: cfscript function StripHTML(str) { return REReplaceNoCase(str,[^]*,br,ALL); } /cfscript cfset logtext = table trtdpspan class=bodyThis is some example text/span/p/td/tr trtdbFriday 17 march, 2006/bbr12:54 PM/td/tr /table cfset str = StripHTML(logtext) The above script strips out the everything between the opening and closing angle brackets and . Is there any way to tell the regular expression to do the above but not process the following tags: b, br, span, i, strong, div, p I would be really greatful if someone could post the regular expression to do this. Best regards, cfcoder ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237697 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Regular Expressions - Strip HTML tags. Please help!!!
Not sure if this has been suggested (coming in late), but this function works well. http://www.cflib.org/udf.cfm?ID=774 (Thanks Isaac) Not a simple regex, but it gets the job done. On 4/13/06, cf coder [EMAIL PROTECTED] wrote: Hello Everybody, I need your help with regular expressions. I'm trying to strip out HTML tags from a string to pass it to a flash movie. I've found a script that does this but the problem is that I want to keep some html formatting specifically the following tags: b, br, span, i, strong, div, p ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237699 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Regular Expressions - Strip HTML tags. Please help!!!
Yeah I hawked it. :P Thanks Jerry. I love that people like this function so much, it makes me smile whenever I see it recommended, because I know I've helped them. :) I wrote an article for CFDJ that should be in the next issue(?) about an alternative approach of using XML and a CFC to handle user-provided xhtml content and remove tags. Not sure if this has been suggested (coming in late), but this function works well. http://www.cflib.org/udf.cfm?ID=774 (Thanks Isaac) Not a simple regex, but it gets the job done. On 4/13/06, cf coder [EMAIL PROTECTED] wrote: Hello Everybody, I need your help with regular expressions. I'm trying to strip out HTML tags from a string to pass it to a flash movie. I've found a script that does this but the problem is that I want to keep some html formatting specifically the following tags: b, br, span, i, strong, div, p s. isaac dealey 434.293.6201 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237703 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Regular Expressions - Strip HTML tags. Please help!!!
CFLib.org is your friend :) Check out the function called StripTags. It does exactly what you want. http://www.cflib.org/udf.cfm?ID=774 Cedric ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237707 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Regular Expressions - Strip HTML tags. Please help!!!
HI cfCoder You could try something along these lines: reReplaceNoCase(str,(font)[^]*,,all) replaceNoCase(returnStr,/font,,all) You could then be selective to the tags you wish to strip out. Hope this helps. All the best Jose Diaz On 4/13/06, cf coder [EMAIL PROTECTED] wrote: Hello Everybody, I need your help with regular expressions. I'm trying to strip out HTML tags from a string to pass it to a flash movie. I've found a script that does this but the problem is that I want to keep some html formatting specifically the following tags: b, br, span, i, strong, div, p Here is the code: cfscript function StripHTML(str) { return REReplaceNoCase(str,[^]*,br,ALL); } /cfscript cfset logtext = table trtdpspan class=bodyThis is some example text/span/p/td/tr trtdbFriday 17 march, 2006/bbr12:54 PM/td/tr /table cfset str = StripHTML(logtext) The above script strips out the everything between the opening and closing angle brackets and . Is there any way to tell the regular expression to do the above but not process the following tags: b, br, span, i, strong, div, p I would be really greatful if someone could post the regular expression to do this. Best regards, cfcoder ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237725 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Regular Expressions: Extract code between BODY tags
rereplacenocase(string, 'body[^]*(.+)/body', \1) Your looking for the body tag with anything in it, then everything after that body tag that does not include the ending body tag. Using REReplace is the most efficient here as your peeling off what you don't want (i.e. whats not body content) _ From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 10:48 AM To: CF-Talk Subject: Regular Expressions: Extract code between BODY tags All: I have a complete HTML file, beginning with doctype declaration and ending with a closing HTML tag, from which I'd like to programmatically strip away everything but the code between (and not including) the BODY tags.That is, only the code (including tags) between the BODY tags should remain.Can anyone provide the RE to accomplish this? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
You, sir, are a saint.Thank you. Here's the code I ended up using: REReplaceNoCase(contents, '.+body[^]*(.+)/body.+', \1) As it was, it removed the BODY tags but not the contents before and after them. Again, thanks. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ Michael Dinowitz wrote: rereplacenocase(string, 'body[^]*(.+)/body', \1) Your looking for the body tag with anything in it, then everything after that body tag that does not include the ending body tag. Using REReplace is the most efficient here as your peeling off what you don't want (i.e. whats not body content) [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
The additions are correct. I was a bit hasty in my posting. _ From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 11:20 AM To: CF-Talk Subject: RE: Regular Expressions: Extract code between BODY tags You, sir, are a saint.Thank you. Here's the code I ended up using: REReplaceNoCase(contents, '.+body[^]*(.+)/body.+', \1) As it was, it removed the BODY tags but not the contents before and after them. Again, thanks. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ Michael Dinowitz wrote: rereplacenocase(string, 'body[^]*(.+)/body', \1) Your looking for the body tag with anything in it, then everything after that body tag that does not include the ending body tag. Using REReplace is the most efficient here as your peeling off what you don't want (i.e. whats not body content) _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
Actually this should be rereplacenocase(string, '.*body[^]*(.+)/body.*', \1) Pascal -Original Message- From: Michael Dinowitz [mailto:[EMAIL PROTECTED] Sent: 14 September 2004 16:54 To: CF-Talk Subject: [Spam?] RE: Regular Expressions: Extract code between BODY tags rereplacenocase(string, 'body[^]*(.+)/body', \1) Your looking for the body tag with anything in it, then everything after that body tag that does not include the ending body tag. Using REReplace is the most efficient here as your peeling off what you don't want (i.e. whats not body content) _ From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 10:48 AM To: CF-Talk Subject: Regular Expressions: Extract code between BODY tags All: I have a complete HTML file, beginning with doctype declaration and ending with a closing HTML tag, from which I'd like to programmatically strip away everything but the code between (and not including) the BODY tags. That is, only the code (including tags) between the BODY tags should remain. Can anyone provide the RE to accomplish this? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
Cool.Again, thanks. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ Michael Dinowitz wrote: The additions are correct. I was a bit hasty in my posting. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
Either the .* or the .+ will work as the original poster said that the body tags would be within a validly formatted HTML document. This brings up a question of the relative merits of the * and + modifiers when doing large matches. I'll have to look in Mastering RegEx if there's any known speed or overhead differences. I doubt it, but :) _ From: Pascal Peters [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 11:25 AM To: CF-Talk Subject: RE: Regular Expressions: Extract code between BODY tags Actually this should be rereplacenocase(string, '.*body[^]*(.+)/body.*', \1) Pascal -Original Message- From: Michael Dinowitz [mailto:[EMAIL PROTECTED] Sent: 14 September 2004 16:54 To: CF-Talk Subject: [Spam?] RE: Regular Expressions: Extract code between BODY tags rereplacenocase(string, 'body[^]*(.+)/body', \1) Your looking for the body tag with anything in it, then everything after that body tag that does not include the ending body tag. Using REReplace is the most efficient here as your peeling off what you don't want (i.e. whats not body content) _ From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 10:48 AM To: CF-Talk Subject: Regular Expressions: Extract code between BODY tags All: I have a complete HTML file, beginning with doctype declaration and ending with a closing HTML tag, from which I'd like to programmatically strip away everything but the code between (and not including) the BODY tags. That is, only the code (including tags) between the BODY tags should remain. Can anyone provide the RE to accomplish this? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular Expressions: Extract code between BODY tags
I posted this before the answer from Mosh, but our mail is going out very slowly lately. It was a correction on your post (.* OR .+ was missing before and after your regexp), not on Mosh's second post (that I didn't have at that time). .+ or .* will of course both work and I also doubt there is any difference. Pascal -Original Message- From: Michael Dinowitz [mailto:[EMAIL PROTECTED] Sent: 14 September 2004 17:34 To: CF-Talk Subject: [Spam?] RE: Regular Expressions: Extract code between BODY tags Either the .* or the .+ will work as the original poster said that the body tags would be within a validly formatted HTML document. This brings up a question of the relative merits of the * and + modifiers when doing large matches. I'll have to look in Mastering RegEx if there's any known speed or overhead differences. I doubt it, but :) [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: Regular expressions
I am not 100% percent sure, but my mind tells me you can't run a CF function on the backreference value in a regular _expression_. Jerry Johnson [EMAIL PROTECTED] 07/07/04 02:48PM Can someone tell me why the following code will not work: cfset myvar = REReplace(myvar, %([[:xdigit:]]{2}), urlDecode('\1'), ALL) I am trying to write a function that will take the filecontent from a cfhttp request and unescape any hexidecimal sequences it finds (for example %20 for a space. I am trying to use backreferencing with a regular _expression_ to find these sequences and then unescape them using urlDecode. I've already tried passing the entire string into urlDecode but it won't take it. Thanks, Joe [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular expressions
Rereplace takes 4 strings, it doesn't take any expressions.To put it another way, any expressions you place inside the function call are evaluated into strings, and then the strings are passed to the Rereplace call.The only processing you can use inside the replace string is that which the RE engine exposes, you can't use any CF processing.If you want to do that, then you have to manually loop over the string, and perform the given operation manually. Cheers, barneyb -Original Message- From: Joe Bernard [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 07, 2004 11:49 AM To: CF-Talk Subject: Regular expressions Can someone tell me why the following code will not work: cfset myvar = REReplace(myvar, %([[:xdigit:]]{2}), urlDecode('\1'), ALL) I am trying to write a function that will take the filecontent from a cfhttp request and unescape any hexidecimal sequences it finds (for example %20 for a space. I am trying to use backreferencing with a regular _expression_ to find these sequences and then unescape them using urlDecode. I've already tried passing the entire string into urlDecode but it won't take it. Thanks, Joe [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: Regular expressions
Thanks for the help. For anyone who is interested, here is the code I came up with to escape the hex sequences. urlDecode wasn't working right so I used a workaround (inputBaseN). cfloop condition=reFind('%([[:xdigit:]]{2})',filecontent) cfset st = reFind(%([[:xdigit:]]{2}),filecontent,1,true) cfset filecontent = replaceNoCase(filecontent,mid(filecontent,st.pos[1],st.len[1]),chr(inputBaseN(mid(filecontent,st.pos[1]+1,st.len[1]-1),16)),ALL) /cfloop [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Regular expressions in JS (or in general) for dates
You can't do it with only regexp. There is a function in the cfide/scripts/cfform.js file tht does about that. You can validate most of it with /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(\d{2}){1,2}$/ Then extract the day, month and year and see if the day is correct. -Original Message- From: Mark A. Kruger - CFG [mailto:[EMAIL PROTECTED] Sent: vrijdag 11 juni 2004 18:41 To: CF-Talk Subject: OT: Regular expressions in JS (or in general) for dates Regex gurus, I have a string and I want to ensure that the date format is: xx/xx/ or x/x/ or x/x/xx (you get the idea) Does anyone have a stock regex for this?Am I going to need more than 1 or can I look at everything (length, format and range of numbers) in 1 regex? -mark Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com http://blog.mxconsulting.com ...what the web can be! [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Regular expressions in JS (or in general) for dates
function daysInMonth(y,m){ if (m == 4 || m == 6 || m == 9 || m == 11) return 30; else if (m == 2) { if (y % 4 0) return 28; else if (y % 100 == 0 y % 400 0) return 28; else return 29; } else return 31; } function isDate(date){ var date_pattern = /^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/(\d{2}){1,2}$/; if(!date_pattern.test(date)) return false; var aDate = date.split(/); if(aDate[2].length==2) aDate[2] = (eval(aDate[2])30)?19:20 + aDate[2]; alert(aDate[2]+-+aDate[0]+-+aDate[1]); if(eval(aDate[1])daysInMonth(eval(aDate[2]),eval(aDate[0]))) return false; return true; } -Original Message- From: Mark A. Kruger - CFG [mailto:[EMAIL PROTECTED] Sent: vrijdag 11 juni 2004 18:41 To: CF-Talk Subject: OT: Regular expressions in JS (or in general) for dates Regex gurus, I have a string and I want to ensure that the date format is: xx/xx/ or x/x/ or x/x/xx (you get the idea) Does anyone have a stock regex for this?Am I going to need more than 1 or can I look at everything (length, format and range of numbers) in 1 regex? -mark Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com http://blog.mxconsulting.com ...what the web can be! [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Regular expressions in JS (or in general) for dates
Thanks! also thanks to Ben. This is what I needed. -Mark -Original Message- From: Pascal Peters [mailto:[EMAIL PROTECTED] Sent: Friday, June 11, 2004 12:38 PM To: CF-Talk Subject: RE: Regular expressions in JS (or in general) for dates function daysInMonth(y,m){ if (m == 4 || m == 6 || m == 9 || m == 11) return 30; else if (m == 2) { if (y % 4 0) return 28; else if (y % 100 == 0 y % 400 0) return 28; else return 29; } else return 31; } function isDate(date){ var date_pattern = /^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/(\d{2}){1,2}$/; if(!date_pattern.test(date)) return false; var aDate = date.split(/); if(aDate[2].length==2) aDate[2] = (eval(aDate[2])30)?19:20 + aDate[2]; alert(aDate[2]+-+aDate[0]+-+aDate[1]); if(eval(aDate[1])daysInMonth(eval(aDate[2]),eval(aDate[0]))) return false; return true; } -Original Message- From: Mark A. Kruger - CFG [mailto:[EMAIL PROTECTED] Sent: vrijdag 11 juni 2004 18:41 To: CF-Talk Subject: OT: Regular expressions in JS (or in general) for dates Regex gurus, I have a string and I want to ensure that the date format is: xx/xx/ or x/x/ or x/x/xx (you get the idea) Does anyone have a stock regex for this?Am I going to need more than 1 or can I look at everything (length, format and range of numbers) in 1 regex? -mark Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com http://blog.mxconsulting.com ...what the web can be! [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Regular Expressions in CF Studio
I sent it too soon. I used option value=[0-9]* Great! :O) Thanks anyway Jordan -Original Message- From: Jordan Thomas [mailto:[EMAIL PROTECTED] Sent: Tuesday, 9 September 2003 3:50 PM To: CF-Talk Subject: Regular Expressions in CF Studio Hi, I want to remove all of the option tags from a document. For example: option value=001 . option value=100 How do I do a search and replace with CFStudio's Extended Search And Replace with RegEx turned on. I am trying with: option value={[0-9]} But I get no matches. Please help Thanks. Jordan ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. http://www.cfhosting.com
RE: regular expressions (was: please do my work for me)
I'm so sorry about the title - it was originally addressed to a friend but then decided to send it to cf-talk halfway through the email. -Original Message- From: Cantrell, Adam [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 4:38 PM To: CF-Talk Subject: please do my work for me I want to extract a value from a URL variable which can show up anywhere in the URL. Here are some examples, I would want the pCode value which will always be an integer of varying length: index.htm?var1=23pCode=100othervar=hello return 100 index.htm?pCode=1 --- return 1 index.htm?someVariabl=hiTheresomeothervariable=45pCode=00343 223234322 - return 00343223234322 If somebody can tell me the right regular expression (or if a regular expression isn't even needed, but just some combination of CF functions) that would be GREAT! Adam. __ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: regular expressions (was: please do my work for me)
Ooops I'm sorry, I'm actually trying to extract this value from the cgi.HTTP_REFERER variable. Here's what I'm currently using: cfif (isDefined(cgi.HTTP_REFERER)) AND (FindNoCase(pCode=, CGI.HTTP_REFERER)) cfset variables.pCode = mid(cgi.HTTP_REFERER,FindNoCase(pCode=, CGI.HTTP_REFERER)+6,2) /cfif My only problem is when the pCode starts to vary in length - they're not going to be two digits forever. Thanks for any help you can provide. Adam. -Original Message- From: Adrian Lynch [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 4:44 PM To: CF-Talk Subject: RE: please do my work for me Why not just return URL.pCode ? Ade -Original Message- From: Cantrell, Adam [mailto:[EMAIL PROTECTED]] Sent: 25 September 2002 22:38 To: CF-Talk Subject: please do my work for me I want to extract a value from a URL variable which can show up anywhere in the URL. Here are some examples, I would want the pCode value which will always be an integer of varying length: index.htm?var1=23pCode=100othervar=hello return 100 index.htm?pCode=1 --- return 1 index.htm?someVariabl=hiTheresomeothervariable=45pCode=00343 223234322 - return 00343223234322 If somebody can tell me the right regular expression (or if a regular expression isn't even needed, but just some combination of CF functions) that would be GREAT! Adam. __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: regular expressions (was: please do my work for me)
that's messy i think. i would loop through the cgi.http_referer. cfset pCodeValue=No pCode value Found cfloop list=#cgi.http_referer# index=i delimiters= cfif Find(pCode,i) and ListLen(i,=) eq 2 cfset pCodeValue=ListGetAt(i,2,=) /cfif /cfloop cfoutput#pCodeValue#/cfoutput With this, it doesn't matter what the length of pCode value, you will get the exact number returned. Nick Han [EMAIL PROTECTED] 09/25/02 02:48PM Ooops I'm sorry, I'm actually trying to extract this value from the cgi.HTTP_REFERER variable. Here's what I'm currently using: cfif (isDefined(cgi.HTTP_REFERER)) AND (FindNoCase(pCode=, CGI.HTTP_REFERER)) cfset variables.pCode = mid(cgi.HTTP_REFERER,FindNoCase(pCode=, CGI.HTTP_REFERER)+6,2) /cfif My only problem is when the pCode starts to vary in length - they're not going to be two digits forever. Thanks for any help you can provide. Adam. -Original Message- From: Adrian Lynch [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 4:44 PM To: CF-Talk Subject: RE: please do my work for me Why not just return URL.pCode ? Ade -Original Message- From: Cantrell, Adam [mailto:[EMAIL PROTECTED]] Sent: 25 September 2002 22:38 To: CF-Talk Subject: please do my work for me I want to extract a value from a URL variable which can show up anywhere in the URL. Here are some examples, I would want the pCode value which will always be an integer of varying length: index.htm?var1=23pCode=100othervar=hello return 100 index.htm?pCode=1 --- return 1 index.htm?someVariabl=hiTheresomeothervariable=45pCode=00343 223234322 - return 00343223234322 If somebody can tell me the right regular expression (or if a regular expression isn't even needed, but just some combination of CF functions) that would be GREAT! Adam. __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: regular expressions (was: please do my work for me)
Cantrell, Adam wrote: Ooops I'm sorry, I'm actually trying to extract this value from the cgi.HTTP_REFERER variable. Here's what I'm currently using: cfif (isDefined(cgi.HTTP_REFERER)) AND (FindNoCase(pCode=, CGI.HTTP_REFERER)) cfset variables.pCode = mid(cgi.HTTP_REFERER,FindNoCase(pCode=, CGI.HTTP_REFERER)+6,2) /cfif My only problem is when the pCode starts to vary in length - they're not going to be two digits forever. Thanks for any help you can provide. Adam. REreplace(str, [.]*pCode=([^]*)[.]*, \1); could do it... but I haven't tested it. Jesse __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: regular expressions (was: please do my work for me)
why not just do something like cfset pCode = ListLast(ListGetAt(ListLast(CGI.HTTP_REFERER, ?), ListFindNoCase(ListLast(CGI.HTTP_REFERER, ?), pCode, ), ), =) its a bit messy and untested - but... -Original Message- From: Nick Han [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 3:19 PM To: CF-Talk Subject: RE: regular expressions (was: please do my work for me) that's messy i think. i would loop through the cgi.http_referer. cfset pCodeValue=No pCode value Found cfloop list=#cgi.http_referer# index=i delimiters= cfif Find(pCode,i) and ListLen(i,=) eq 2 cfset pCodeValue=ListGetAt(i,2,=) /cfif /cfloop cfoutput#pCodeValue#/cfoutput With this, it doesn't matter what the length of pCode value, you will get the exact number returned. Nick Han [EMAIL PROTECTED] 09/25/02 02:48PM Ooops I'm sorry, I'm actually trying to extract this value from the cgi.HTTP_REFERER variable. Here's what I'm currently using: cfif (isDefined(cgi.HTTP_REFERER)) AND (FindNoCase(pCode=, CGI.HTTP_REFERER)) cfset variables.pCode = mid(cgi.HTTP_REFERER,FindNoCase(pCode=, CGI.HTTP_REFERER)+6,2) /cfif My only problem is when the pCode starts to vary in length - they're not going to be two digits forever. Thanks for any help you can provide. Adam. -Original Message- From: Adrian Lynch [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 4:44 PM To: CF-Talk Subject: RE: please do my work for me Why not just return URL.pCode ? Ade -Original Message- From: Cantrell, Adam [mailto:[EMAIL PROTECTED]] Sent: 25 September 2002 22:38 To: CF-Talk Subject: please do my work for me I want to extract a value from a URL variable which can show up anywhere in the URL. Here are some examples, I would want the pCode value which will always be an integer of varying length: index.htm?var1=23pCode=100othervar=hello return 100 index.htm?pCode=1 --- return 1 index.htm?someVariabl=hiTheresomeothervariable=45pCode=00343 223234322 - return 00343223234322 If somebody can tell me the right regular expression (or if a regular expression isn't even needed, but just some combination of CF functions) that would be GREAT! Adam. __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: regular expressions (was: please do my work for me)
: REreplace(str, [.]*pCode=([^]*)[.]*, \1); This won't work. The brackets around the dot make it a literal character, so it won't match what's leading or following the pcode bit. Essentially, all this will do is strip pcode= out of the url. --Ben Doom Programmer General Lackey Moonbow Software __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions
Posted this yesterday, but it never made it on the list. I'm a little rusty on my regular expressions. Can somebody help me out with these two that I'm having problems with. The first is cfset st1 = REFindNoCase('Our New Price: font color=.?AA\$([0-9\.]+)BR/font',testString,1,TRUE) cfset price=Mid(testString,st1.pos[2],st1.len[2]) cfoutput#price#/cfoutput It's supposed to match Our New Price: font color=#AA$84.00BR/font It works fine, but I think the regex could be better? Try this cfset price = REREplaceNoCase(testString,'Our New Price: font [^]*?\$([\.,0-9]+?)',\1) cfoutput#price#/cfoutput This will ignore any attributes within the font tag so you don't have to worry about them changing... It also sets your price with a single cfset rather than 2 The second one I can't get to match cfset st1 = REFindNoCase('IMG SRC=([.]*) vspace=0 border=0 ALT=[A-Za-z ]+ HEIGHT=125 WIDTH=100',testString,1,TRUE) cfset src=Mid(testString,st1.pos[2],st1.len[2]) cfoutput#src#/cfoutput Is supposed to match td width=1%IMG SRC=http://a1204.g.akamai.net/7/1204/1401/02050212011/images.barnesandn oble.com/images/507/5077366.gif vspace=0 border=0 ALT=Operating Systems HEIGHT=125 WIDTH=100/td and return the URL. Depends on your requirements... Do you need the image specifically which has the ALT attribute of Operating Systems? If so, you might try this: cfset temp = REREplaceNoCase(testString,'(img [^]*?alt=Operating Systems[^]*?)',\1) cfset src = REReplaceNoCase(temp,'href=([^]+?)',\1) The first regex gets your image tag, then the 2nd regex gets the src attribute out of that. This should work even if they move the alt tag around... hth Isaac Dealey Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions
What does [^]*? Mean exactly? I seem to be using something similar in my old code but can't remember what it means. I know perl regular expressions and this doesn't seem to make sense. [^] means expression starting with a then * is a modifier meaning zero or more and ? is a modifier meaning 0 or 1 times. I don't understand how that is legal regex. Is CF regex that much different then perl? Russ -Original Message- From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 03, 2002 10:34 AM To: CF-Talk Subject: Re: Regular Expressions Posted this yesterday, but it never made it on the list. I'm a little rusty on my regular expressions. Can somebody help me out with these two that I'm having problems with. The first is cfset st1 = REFindNoCase('Our New Price: font color=.?AA\$([0-9\.]+)BR/font',testString,1,TRUE) cfset price=Mid(testString,st1.pos[2],st1.len[2]) cfoutput#price#/cfoutput It's supposed to match Our New Price: font color=#AA$84.00BR/font It works fine, but I think the regex could be better? Try this cfset price = REREplaceNoCase(testString,'Our New Price: font [^]*?\$([\.,0-9]+?)',\1) cfoutput#price#/cfoutput This will ignore any attributes within the font tag so you don't have to worry about them changing... It also sets your price with a single cfset rather than 2 The second one I can't get to match cfset st1 = REFindNoCase('IMG SRC=([.]*) vspace=0 border=0 ALT=[A-Za-z ]+ HEIGHT=125 WIDTH=100',testString,1,TRUE) cfset src=Mid(testString,st1.pos[2],st1.len[2]) cfoutput#src#/cfoutput Is supposed to match td width=1%IMG SRC=http://a1204.g.akamai.net/7/1204/1401/02050212011/images.barnesandn oble.com/images/507/5077366.gif vspace=0 border=0 ALT=Operating Systems HEIGHT=125 WIDTH=100/td and return the URL. Depends on your requirements... Do you need the image specifically which has the ALT attribute of Operating Systems? If so, you might try this: cfset temp = REREplaceNoCase(testString,'(img [^]*?alt=Operating Systems[^]*?)',\1) cfset src = REReplaceNoCase(temp,'href=([^]+?)',\1) The first regex gets your image tag, then the 2nd regex gets the src attribute out of that. This should work even if they move the alt tag around... hth Isaac Dealey Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions
: What does [^]*? Mean exactly? I seem to be using something similar in : my old code but can't remember what it means. : : I know perl regular expressions and this doesn't seem to make sense. : [^] means expression starting with a then * is a modifier meaning : zero or more and ? is a modifier meaning 0 or 1 times. I don't : understand how that is legal regex. Is CF regex that much different : then perl? Actually, in both Perl and CF, the carat ^ at the beginning of a class (char group in brackets) means to negate the class -- that is, if []* means match however many characters, then [^]* means match however many characters aren't -- this essentially means grab everything to the end of the tag, in this case. The carat is also used by CF to mark the beginning of the string and by Perl to mark the beginning of the line (assuming you haven't messed with the default delimiters). HTH. --Ben Doom Programmer General Lackey Moonbow Software __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions
What does [^]*? Mean exactly? I seem to be using something similar in my old code but can't remember what it means. [^] means match any character other than * means match 0 or more of the previous expression, so in this case 0 or more of any character other than the ? after the * is probably unnecessary, but I've gotten in the habbit of it -- it makes a * or a + match a minimum number of characters necessary to match the previous expression, as opposed to the default greedy result... In this case it's probably just superfluous. I know perl regular expressions and this doesn't seem to make sense. [^] means expression starting with a then * is a modifier meaning zero or more and ? is a modifier meaning 0 or 1 times. I don't understand how that is legal regex. I'm not sure aobut PERL, but in CF ^ is only start of string if it's at the beginning of the expression, so REFind(^...) will match the beginning of the string ... Starting a character grouping with ^ like this [^0-9] the ^ becomes a not operator, so it's match all characters not in this group. Is CF regex that much different then perl? I wouldn't know, I don't really know much about PERL. Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions
What does [^]*? Mean exactly? I seem to be using something similar in my old code but can't remember what it means. [^] means match any character other than * means match 0 or more of the previous expression, so in this case 0 or more of any character other than the ? after the * is probably unnecessary, but I've gotten in the habbit of it -- it makes a * or a + match a minimum number of characters necessary to match the previous expression, as opposed to the default greedy result... In this case it's probably just superfluous. In CFMX (and in perl compliant RegEx engines) the use of a question mark (?) after a normal modifier such as an asterisk (*) means that the modifier will have a minimal match. Normally, a RegEx portion will try to match everything that it can. If you specify minimal matching, it will only match as much as needed to satisfy the RegEx. If your using the pattern above alone, then it will match with nothing as that's the minimal match and there's nothing else specified in the RegEx. I know perl regular expressions and this doesn't seem to make sense. [^] means expression starting with a then * is a modifier meaning zero or more and ? is a modifier meaning 0 or 1 times. I don't understand how that is legal regex. I'm not sure aobut PERL, but in CF ^ is only start of string if it's at the beginning of the expression, so REFind(^...) will match the beginning of the string ... Starting a character grouping with ^ like this [^0-9] the ^ becomes a not operator, so it's match all characters not in this group. Is CF regex that much different then perl? In 5, yes. In MX, not really. CF 5 uses a merger of the two Posix engines while CFMX uses the Jakata ORO engine. The ORO engine is basically Perl 5 compatible. There are a few caveats, but not many __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Disclaimer: I learned on Perl, so every once in a while, my syntax gets garbled between Perl and CF. Either forgive me or ignore me. There are one or two things you can do to optimize regexps in general. First, maximize the length of any mandatory fixed string. That is, if you know a substring will always be present in the same position, put that substring in your regexp. So, if you are trying to match all the following: Ben is cool. Ben is smart. Ben is pretty decent at regular expressions, having come from a Perl background. You would use something like Ben is [a-zA-Z ]*\. to use Ben is and the trailing period to limit the length of string the parser has to search for the dynamic bits. Second, think about the number of comparisons to make. Typically, the fewer comparisons the parser makes to match properly, the faster it runs. So, to validate that something looks like an HTML tag, we could look for: '[a-zA-Z[:space:]_=]' Or we could look for '[^]' Which, with every parser I've ever seen, will run slightly faster. The only other thing I'd say is that when I write regexps, I don't think too much about speed until I'm sure that I've got one that finds exactly what I want, only what I want, and always captures what I want. To me, accuracy is more important that saving cycles. --Ben Doom Programmer General Lackey Moonbow Software __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
Ben is forgetting that CF 5 and earlier RegEx are greedy and his example will get a lot more than just from Ben to the period. It'll get from Ben to the last period on the page or string. This would work better in CF5 and earlier Ben is [^.]*\. Note that there's really just one type of comparison. Is the character a period or not. Ben is [a-zA-Z ]*?\. would work in MX. Note the ? after the asterisk. it says get all of a-z but only as many as needed to fulfill the requirements. Be stingy. But its still doing more comparisons. If the character an a? a b? a c? etc. So, if you are trying to match all the following: Ben is cool. Ben is smart. Ben is pretty decent at regular expressions, having come from a Perl background. You would use something like Ben is [a-zA-Z ]*\. to use Ben is and the trailing period to limit the length of string the parser has to search for the dynamic bits. Second, think about the number of comparisons to make. Typically, the fewer comparisons the parser makes to match properly, the faster it runs. So, to validate that something looks like an HTML tag, we could look for: '[a-zA-Z[:space:]_=]' Or we could look for '[^]' Which, with every parser I've ever seen, will run slightly faster. The only other thing I'd say is that when I write regexps, I don't think too much about speed until I'm sure that I've got one that finds exactly what I want, only what I want, and always captures what I want. To me, accuracy is more important that saving cycles. --Ben Doom Programmer General Lackey Moonbow Software __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
BTW, thanks for reminding me I have to write up a section on optimal RegEx. Michael Dinowitz Master of the House of Fusion http://www.houseoffusion.com - Original Message - From: Ben Doom [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 9:36 AM Subject: RE: Regular Expressions/Speed Disclaimer: I learned on Perl, so every once in a while, my syntax gets garbled between Perl and CF. Either forgive me or ignore me. There are one or two things you can do to optimize regexps in general. First, maximize the length of any mandatory fixed string. That is, if you know a substring will always be present in the same position, put that substring in your regexp. So, if you are trying to match all the following: Ben is cool. Ben is smart. Ben is pretty decent at regular expressions, having come from a Perl background. You would use something like Ben is [a-zA-Z ]*\. to use Ben is and the trailing period to limit the length of string the parser has to search for the dynamic bits. Second, think about the number of comparisons to make. Typically, the fewer comparisons the parser makes to match properly, the faster it runs. So, to validate that something looks like an HTML tag, we could look for: '[a-zA-Z[:space:]_=]' Or we could look for '[^]' Which, with every parser I've ever seen, will run slightly faster. The only other thing I'd say is that when I write regexps, I don't think too much about speed until I'm sure that I've got one that finds exactly what I want, only what I want, and always captures what I want. To me, accuracy is more important that saving cycles. --Ben Doom Programmer General Lackey Moonbow Software __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
: Ben is forgetting that CF 5 and earlier RegEx are greedy and his : example will get a lot more than just from Ben to the period. : It'll get from Ben to the last period on the page or string. : This would work better in CF5 and earlier : Ben is [^.]*\. : Note that there's really just one type of comparison. Is the : character a period or not. : Ben is [a-zA-Z ]*?\. : would work in MX. Note the ? after the asterisk. it says get all : of a-z but only as many as needed to fulfill the requirements. Be : stingy. But its still doing more comparisons. If the character an : a? a b? a c? etc. Actually, Ben was trying to use trivial examples to be clear. But point taken. :-) --Ben Doom Programmer General Lackey Moonbow Software __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
Have you played with the MX RegEx any? : Ben is forgetting that CF 5 and earlier RegEx are greedy and his : example will get a lot more than just from Ben to the period. : It'll get from Ben to the last period on the page or string. : This would work better in CF5 and earlier : Ben is [^.]*\. : Note that there's really just one type of comparison. Is the : character a period or not. : Ben is [a-zA-Z ]*?\. : would work in MX. Note the ? after the asterisk. it says get all : of a-z but only as many as needed to fulfill the requirements. Be : stingy. But its still doing more comparisons. If the character an : a? a b? a c? etc. Actually, Ben was trying to use trivial examples to be clear. But point taken. :-) --Ben Doom Programmer General Lackey Moonbow Software __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
Ben is forgetting that CF 5 and earlier RegEx are greedy and his example will get a lot more than just from Ben to the period. It'll get from Ben to the last period on the page or string. This would work better in CF5 and earlier Ben is [^.]*\. Note that there's really just one type of comparison. Is the character a period or not. Ben is [a-zA-Z ]*?\. would work in MX. Note the ? after the asterisk. it says get all of a-z but only as many as needed to fulfill the requirements. Be stingy. But its still doing more comparisons. If the character an a? a b? a c? etc. Is the ? in that string part of an attempt on MM's part to not make people have to rewrite their existing expressions, or is that just the way it works? Isaac Dealey www.turnkey.to 954-776-0046 __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
I'm not sure what you mean by your question. Rewrite their existing expressions from what? Perl? Maybe. The new syntax is very Perl-like. -- The ? is a new 'command' in MX RegEx that tells the previous special character to only operate as many times as needed but not more. For example, string = this is a test [a-z]+ will match the whole string [a-z]+? will match t The t is the minimum amount that will satisfy the + modifier. Ben is [a-zA-Z ]*?\. would work in MX. Note the ? after the asterisk. it says get all of a-z but only as many as needed to fulfill the requirements. Be stingy. But its still doing more comparisons. If the character an a? a b? a c? etc. Is the ? in that string part of an attempt on MM's part to not make people have to rewrite their existing expressions, or is that just the way it works? Isaac Dealey www.turnkey.to 954-776-0046 __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Ben is [a-zA-Z ]*?\. : would work in MX. Note the ? after the asterisk. it says get all of a-z : but only as many as needed to fulfill the requirements. Be : stingy. But its : still doing more comparisons. If the character an a? a b? a c? etc. : : Is the ? in that string part of an attempt on MM's part to not make people : have to rewrite their existing expressions, or is that just the way it : works? Hmm. That's the way it works in Perl, and in the latest regex RFC spec IIRC. I'm not sure what you mean by make people have to rewrite their existing expressions though. I never worked with earlier versions of CF, so I don't know if earlier versions of the RegEx parser weren't greedy, but that'd be unusual. --Ben Doom Programmer General Lackey Moonbow Software __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
: Have you played with the MX RegEx any? Nope. We're running CF 5 here. After working in Perl for years, I'll freely admit (gripe? yell? complain bitterly?) that the CF 5 regexps don't quite stack up. Is the CFMX RexEx parser any better? Not that that'd convince my boss to upgrade. If it ain't broke, don't fix it, I suppose. --Ben Doom Programmer General Lackey Moonbow Software __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
CF RegEx has been greedy from day 1. The new ? addition gives the option for stingy matches. : Is the ? in that string part of an attempt on MM's part to not make people : have to rewrite their existing expressions, or is that just the way it : works? Hmm. That's the way it works in Perl, and in the latest regex RFC spec IIRC. I'm not sure what you mean by make people have to rewrite their existing expressions though. I never worked with earlier versions of CF, so I don't know if earlier versions of the RegEx parser weren't greedy, but that'd be unusual. --Ben Doom Programmer General Lackey Moonbow Software __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Nope. We're running CF 5 here. After working in Perl for years, I'll freely admit (gripe? yell? complain bitterly?) that the CF 5 regexps don't quite stack up. Is the CFMX RexEx parser any better? Much. It's very close to be being 100% compat with Perl. === Raymond Camden, ColdFusion Jedi Master for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Nope. We're running CF 5 here. After working in Perl for years, I'll freely admit (gripe? yell? complain bitterly?) that the CF 5 regexps don't quite stack up. Is the CFMX RexEx parser any better? Not that that'd convince my boss to upgrade. If it ain't broke, don't fix it, I suppose. While CF MX is really, really nice, and speaking as a Macromedia partner, I'd recommend that you buy it right away - and get extra copies for the family, the dog, etc. - if you're running CF 5 on Windows, you might want to take a look at this: http://www.rixsoft.com/ColdFusion/CFX/PCRegEx/ It's a Perl-compatible regex engine within a CFX. Enjoy! Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
I'm not sure what you mean by your question. Rewrite their existing expressions from what? Perl? Maybe. The new syntax is very Perl-like. I meant from CF 5 and earlier ... the greedy regex ... -- The ? is a new 'command' in MX RegEx that tells the previous special character to only operate as many times as needed but not more. For example, string = this is a test [a-z]+ will match the whole string [a-z]+? will match t The t is the minimum amount that will satisfy the + modifier. Didn't ? match 0-1 instance of a given character or sub-expression? Was this behavior modified in MX to work with * and + or is this just the way it works? Isaac www.turnkey.to 954-776-0046 __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
I'm not sure what you mean by your question. Rewrite their existing expressions from what? Perl? Maybe. The new syntax is very Perl-like. I meant from CF 5 and earlier ... the greedy regex ... Greedy is the base for all RegEx. -- The ? is a new 'command' in MX RegEx that tells the previous special character to only operate as many times as needed but not more. For example, string = this is a test [a-z]+ will match the whole string [a-z]+? will match t The t is the minimum amount that will satisfy the + modifier. Didn't ? match 0-1 instance of a given character or sub-expression? Was this behavior modified in MX to work with * and + or is this just the way it works? Yes, but note that the ? is after another modifier such as + or *. That means its modifying the modifer, not the character or character set. Isaac www.turnkey.to 954-776-0046 __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
I'm not sure what you mean by your question. Rewrite their existing expressions from what? Perl? Maybe. The new syntax is very Perl-like. I meant from CF 5 and earlier ... the greedy regex ... Greedy is the base for all RegEx. Oh okay, thanks for the clarification. -- The ? is a new 'command' in MX RegEx that tells the previous special character to only operate as many times as needed but not more. For example, string = this is a test [a-z]+ will match the whole string [a-z]+? will match t The t is the minimum amount that will satisfy the + modifier. Didn't ? match 0-1 instance of a given character or sub-expression? Was this behavior modified in MX to work with * and + or is this just the way it works? Yes, but note that the ? is after another modifier such as + or *. That means its modifying the modifer, not the character or character set. cool, thanks. :) Isaac www.turnkey.to 954-776-0046 __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions/Speed
What regex library are you using? That's the defining factor --the parser. Just like xml parsers are different so are regex libs/utilities. On Tue, 9 Jul 2002, Cornillon, Matthieu wrote: Does anyone have anything concrete to say about the speed of searching using regular expressions? Are giant RegExes a mistake? I am hardly seeing any performance hit at all right now with mine, which is quite big. Of course, I am not live with piles of simultaneous users, either. Am I going to hit trouble? Does anyone have any feedback on optimization of RegExes (i.e., is on(click|mouseup|mousedown) much different from onclick|onmousedown|onmouseup from on(click|(mouse(up|down)))? TIA, Matthieu __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Oops. Gulp. (And other sounds of cringing terror.) Er...what's a regex library? Matthieu -Original Message- From: Alex [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 09, 2002 9:55 PM To: CF-Talk Subject: Re: Regular Expressions/Speed What regex library are you using? That's the defining factor --the parser. Just like xml parsers are different so are regex libs/utilities. On Tue, 9 Jul 2002, Cornillon, Matthieu wrote: Does anyone have anything concrete to say about the speed of searching using regular expressions? Are giant RegExes a mistake? I am hardly seeing any performance hit at all right now with mine, which is quite big. Of course, I am not live with piles of simultaneous users, either. Am I going to hit trouble? Does anyone have any feedback on optimization of RegExes (i.e., is on(click|mouseup|mousedown) much different from onclick|onmousedown|onmouseup from on(click|(mouse(up|down)))? TIA, Matthieu __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions/Speed
Oops. Gulp. (And other sounds of cringing terror.) Er...what's a regex library? You're using the default regex library that's native to whatever version of CF you're using... I've heard that the regex libraries in cfmx are better -- not having the 2000 character limitation and possibly faster and closer in practice to PERL's interpretation of the syntax. There were some complaints about regex in previous versions of CF server although I never had any problems with it personally... You had to occasionally get creative if you suspected there might be a chance the string would be over 2000 characters... and then you'd wonder is my script going to chop something in half that would otherwise be seen by the regex? ... I'm not sure about optimizations specifically -- I'm usually happy to have it working. :) Though if you need to validate a short variable with exacting standards ( like a url, email address, etc ), it's certainly going to be a lot faster than performing a bucket-full of other evaluations of length, data type, etc... development time may be similar depending on your comfortability with regex tho. :) Isaac www.turnkey.to 954-776-0046 __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
http://www.houseoffusion.com/RegEx.ppt -Original Message- From: Dowdell, Jason G [mailto:[EMAIL PROTECTED]] Sent: maandag 11 maart 2002 13:48 To: CF-Talk Subject: Regular expressions Hi all, I'm looking for a good tutorial/reference manual for regualar expressions. Being that I came from a business background and the majority of my coding knowledge is self taught I don't have some of the basic elements a computer science major would. I'm looking for a good guide on regular expressions in general and regular expressions in ColdFusion. If anyone knows of any I'd appreciate a post. Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Name that movie :0) Thanks, Jason !---/// Jason Dowdell IM East 321.799.6845 [EMAIL PROTECTED] ///--- __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
http://www.amazon.com/exec/obidos/ASIN/1565922573/qid=1015855436/sr=8-1/ ref=sr_8_67_1/102-6894441-0446552 -Original Message- From: Dowdell, Jason G [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 4:48 AM To: CF-Talk Subject: Regular expressions Hi all, I'm looking for a good tutorial/reference manual for regualar expressions. Being that I came from a business background and the majority of my coding knowledge is self taught I don't have some of the basic elements a computer science major would. I'm looking for a good guide on regular expressions in general and regular expressions in ColdFusion. If anyone knows of any I'd appreciate a post. Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Name that movie :0) Thanks, Jason !---/// Jason Dowdell IM East 321.799.6845 [EMAIL PROTECTED] ///--- __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
http://www.houseoffusion.com/RegEx.ppt Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. No way. That's clearly an Office Space reference. In the future, let's try not to confuse any line from Dude Where's My Car with any other self-respecting movie. It's just not right. Regards, Dave. _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
The answer I was looking for was Office Space. Fortunately, I've never seen Dude Where's My Car? but I can see that the majority of the people on this list are familiar with cubicle life. Thanks to everyone for their input on the regex guides. The powerpoint on HouseofFusion was quite good and I'll also go get the reference manual from O'Reilly press as well. Thanks again, Jason -Original Message- From: Dave Carabetta [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 10:55 AM To: CF-Talk Subject: RE: Regular expressions Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. No way. That's clearly an Office Space reference. In the future, let's try not to confuse any line from Dude Where's My Car with any other self-respecting movie. It's just not right. Regards, Dave. _ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
there's also a ppt file on reg ex at cfugorama.com. Go to the library, then the section on DevCon 2001 presentations. ~Simon Simon Horwith Macromedia Certified Instructor Certified Advanced ColdFusion 5 Developer Fig Leaf Software 1400 16th St NW, # 500 Washington DC 20036 202.797.6570 (direct line) www.figleaf.com -Original Message- From: Dowdell, Jason G [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 11:01 AM To: CF-Talk Subject: RE: Regular expressions The answer I was looking for was Office Space. Fortunately, I've never seen Dude Where's My Car? but I can see that the majority of the people on this list are familiar with cubicle life. Thanks to everyone for their input on the regex guides. The powerpoint on HouseofFusion was quite good and I'll also go get the reference manual from O'Reilly press as well. Thanks again, Jason -Original Message- From: Dave Carabetta [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 10:55 AM To: CF-Talk Subject: RE: Regular expressions Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. No way. That's clearly an Office Space reference. In the future, let's try not to confuse any line from Dude Where's My Car with any other self-respecting movie. It's just not right. Regards, Dave. _ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. No way. That's clearly an Office Space reference. In the future, let's try not to confuse any line from Dude Where's My Car with any other self-respecting movie. It's just not right. Regards, Dave. I guess my quasi-sarcastic tone didn't make the impact I was hoping for. It's almost like asking where It's only a fleshwound! or It's 106 miles to Chicago... came from. The real question is Are there people on the list that DIDN'T know the line?. :) Sorry, way off topic. :/ EC __ Get Your Own Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular expressions
On Mon, 11 Mar 2002, Dave Carabetta wrote: Here's a quote from a great movie most of you should recognize... Sounds like somebody has a case of the Mondays! Hrmmm.. let's see.. must have been from Dude Where's My Car. No way. That's clearly an Office Space reference. In the future, let's try not to confuse any line from Dude Where's My Car with any other self-respecting movie. It's just not right. Regards, Dave. Sweet __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular expressions
A few more :-) http://py-howto.sourceforge.net/regex/regex.html http://gosling.miass.chel.su/books/Perl/3/RegExp_Tutorial.html http://www.cfugorama.com/cfugorama/codelibrary/Regular-Expressions.cfm http://www.boost.org/libs/regex/syntax.htm __ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions in CF Studio
It exists already, however there is no documentation that I could find. The closest I was able to find was the the docs for WizML in studio. However there was no documentation of exact syntax. I tried using some of the functions like putting chr(32) in the find window and putting some random text in the replace window and it found no matches. So it didn't execute my simple function call, just search for that text even though the Regular Expressions checkbox was checked. I am missing something... I have wondered about that checkbox...anybody know what's up with it? jon - Original Message - From: Brad Roberts [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Friday, May 25, 2001 12:39 AM Subject: RE: Regular Expressions in CF Studio Sorry. I haven't heard of it, but that would be cool! -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 9:21 PM To: CF-Talk Subject: RE: Regular Expressions in CF Studio I am talking about using regular expressions with the find and replace options in cfstudio, I already read Michaels help file. Bob Everland -Original Message- From: Brad Roberts [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 8:04 PM To: CF-Talk Subject: RE: Regular Expressions in CF Studio I don't think Studio covers it in the docs, but it does provide an expression builder: right click -- Insert Expression. Check out the Power Point tutorial from Micheal Dinowitz on houseoffusion.com http://www.houseoffusion.com/RegEx.ppt Also, http://www.houseoffusion.com/httpagent.ppt HTH, Brad -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 7:43 PM To: CF-Talk Subject: Regular Expressions in CF Studio I can't find how to use Regular Expressions in CF Studio. can anyone proveide an example or a webpage on how to do it. Bob Everland ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions in CF Studio
I don't think Studio covers it in the docs, but it does provide an expression builder: right click -- Insert Expression. Check out the Power Point tutorial from Micheal Dinowitz on houseoffusion.com http://www.houseoffusion.com/RegEx.ppt Also, http://www.houseoffusion.com/httpagent.ppt HTH, Brad -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 7:43 PM To: CF-Talk Subject: Regular Expressions in CF Studio I can't find how to use Regular Expressions in CF Studio. can anyone proveide an example or a webpage on how to do it. Bob Everland ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions in CF Studio
I am talking about using regular expressions with the find and replace options in cfstudio, I already read Michaels help file. Bob Everland -Original Message- From: Brad Roberts [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 8:04 PM To: CF-Talk Subject: RE: Regular Expressions in CF Studio I don't think Studio covers it in the docs, but it does provide an expression builder: right click -- Insert Expression. Check out the Power Point tutorial from Micheal Dinowitz on houseoffusion.com http://www.houseoffusion.com/RegEx.ppt Also, http://www.houseoffusion.com/httpagent.ppt HTH, Brad -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 7:43 PM To: CF-Talk Subject: Regular Expressions in CF Studio I can't find how to use Regular Expressions in CF Studio. can anyone proveide an example or a webpage on how to do it. Bob Everland ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions in CF Studio
Sorry. I haven't heard of it, but that would be cool! -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 9:21 PM To: CF-Talk Subject: RE: Regular Expressions in CF Studio I am talking about using regular expressions with the find and replace options in cfstudio, I already read Michaels help file. Bob Everland -Original Message- From: Brad Roberts [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 8:04 PM To: CF-Talk Subject: RE: Regular Expressions in CF Studio I don't think Studio covers it in the docs, but it does provide an expression builder: right click -- Insert Expression. Check out the Power Point tutorial from Micheal Dinowitz on houseoffusion.com http://www.houseoffusion.com/RegEx.ppt Also, http://www.houseoffusion.com/httpagent.ppt HTH, Brad -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 24, 2001 7:43 PM To: CF-Talk Subject: Regular Expressions in CF Studio I can't find how to use Regular Expressions in CF Studio. can anyone proveide an example or a webpage on how to do it. Bob Everland ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: regular expressions, anyone?
Badtags = "B|P|HR|PRE"; Expression = "[[:space:]]?/?[[:space:]]?(#Badtags#)[^]*"; Message = REReplaceNoCase(Message, Expression, '', 'ALL'); i'm completely new to regular expressions, but my understanding is that they can be used to perform multiple find/replace all in one exception. i have a string that i must filter for several HTML tags before continuing. the code follows. how would i write a regular expression to perform all? cfscript newStr = ReplaceNoCase(newStr,"b","","ALL"); newStr = ReplaceNoCase(newStr,"/b",".","ALL"); newStr = ReplaceNoCase(newStr,"p","","ALL"); newStr = ReplaceNoCase(newStr,"/p","","ALL"); newStr = ReplaceNoCase(newStr,"hr"," ","ALL"); newStr = ReplaceNoCase(newStr,"pre","","ALL"); newStr = ReplaceNoCase(newStr,"/pre","","ALL"); newStr = ReplaceNoCase(newStr,"hr"," ","ALL"); /cfscript -mike ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions
The best reference I've found is actually in the CFStudio help files... Check under "Using ColdFusion Studio" - "12 Testing and Maintaining Web Pages" - "Using Find and Replace" This reference is for CF Studio, but the rules seem to be the same for the language itself. If you want perl compatible regex's, there's a CFX_PCREGEX out there, I think.I can't remember the url...if you have trouble finding it, e-mail me offlist and I'll dig it up. Jason Powers Fig Leaf Software 202-797-5440 -Original Message- From: Scott, Andrew [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 13, 2001 9:55 PM To: CF-Talk Subject: Regular Expressions Are there any documents, or resource sites on Regular Expressions under CF. What I am looking for are what limitations are there associated with RegEx's under CF... regards Andrew Scott Senior Coldfusion Application Developer -Original Message- From: Mak Wing Lok [mailto:[EMAIL PROTECTED]] Sent: 14 February 2001 10:23 To: CF-Talk Subject: Re: as400 connection Please, and thanks. - Original Message - From: Peter J. MacDonald [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, February 14, 2001 12:17 AM Subject: RE: as400 connection Yes, it could talk AS400. There are some ODBC's out there for it. There is also an OLE DB driver that is more stable. I could get the name of the OLE DB driver if you need it I do not have it handy right now. Thank You, Peter Peter J. MacDonald II Creative Computing, Inc. 100 Middle Street Lincoln, RI 02865 Phone: 401.727.0183 x123 Fax: 401.727.4998 Portable: 401.965.3661 E-MAIL: [EMAIL PROTECTED] Web Page: www.creatcomp.com -Original Message- From: Mak Wing Lok [mailto:[EMAIL PROTECTED]] Sent: Monday, February 12, 2001 23:11 To: CF-Talk Subject: as400 connection hi people, did anyone know that if it is possible for CF server to "talk" to AS/400 machine? advise needed, thanks ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: regular expressions
Thanks. I hadn't seen MD's post. -Original Message- From: Bill Davidson [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 16, 2000 11:21 PM To: CF-Talk Subject: Re: regular expressions umm.. Look back 2 messages... It's from Fusion Authority, so I'm sure its good... www.houseoffusion.com/httpagent.ppt ;) (I realize you may have sent this message before Michael's message posted.) -Bill /intraget - Original Message - From: Craig Thomas [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Saturday, December 16, 2000 9:04 PM Subject: regular expressions Does anyone know of a good source of info on Regular Expressions for CF? Craig ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: regular expressions
umm.. Look back 2 messages... It's from Fusion Authority, so I'm sure its good... www.houseoffusion.com/httpagent.ppt ;) (I realize you may have sent this message before Michael's message posted.) -Bill /intraget - Original Message - From: Craig Thomas [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Saturday, December 16, 2000 9:04 PM Subject: regular expressions Does anyone know of a good source of info on Regular Expressions for CF? Craig ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions - Programming Interface?
Hey Don, take a look at: http://www.cfcomet.com/cfcomet/other/index.cfm?ArticleID=F0A14065-EF7A-4A9E- AED5F28EF8C19D65 it's a pretty good resource for a beginning Reg Exer. ~Simon Simon Horwith Certified ColdFusion Developer Fig Leaf Software 1400 16th St NW, # 220 Washington DC 20036 202.797.6570 (direct line) www.figleaf.com -Original Message- From: Don Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 07, 2000 10:57 AM To: CF-Talk Subject: Regular Expressions - Programming Interface? Per a discussion at last night's CFUG, Is anyone aware of any programming interface that would help new programmers learn to write regular expressions? Preferably Perl-style REs, but actually I would be interested to see if anyone has some kind of "regular expression builder" or programming interface for CF, Perl or any RE-capable language. I am not sure what this would look like, but like many of us I have been casually writing REs by hand for the last 8 years and I don't remember ever seeing anything to assist new programmers other than books. thanks for any info, Don ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions - Programming Interface?
Don: I would like to have the same thing. That is a good idea. Greg - Original Message - From: "Don Smith" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Thursday, December 07, 2000 10:56 AM Subject: Regular Expressions - Programming Interface? Per a discussion at last night's CFUG, Is anyone aware of any programming interface that would help new programmers learn to write regular expressions? Preferably Perl-style REs, but actually I would be interested to see if anyone has some kind of "regular expression builder" or programming interface for CF, Perl or any RE-capable language. I am not sure what this would look like, but like many of us I have been casually writing REs by hand for the last 8 years and I don't remember ever seeing anything to assist new programmers other than books. thanks for any info, Don ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions - Programming Interface?
One thing I saw which was pretty cool was a web page with a form with the fields value to test: regex : It used the RE's in javascipt to do the tests, client side , no source editing etcjust an alert box... I can't remember where it is but it chould be replicated easy enough. Of course I have thought about this in respect of a REGEX builder where for example: you would say, here are 10 strings; give me the regex's that will match them. But of course this would be very complicated, especially when you get into '0 or more times' expressions , backrefs etc You probably have to a lot of 'training', and feed the thing a lot of strings that the pattern shouldn't match. It is probably easier to just learn RE's !! But if you find something CC me Justin MacCarthy -Original Message- From: Don Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 07, 2000 3:57 PM To: CF-Talk Subject: Regular Expressions - Programming Interface? Per a discussion at last night's CFUG, Is anyone aware of any programming interface that would help new programmers learn to write regular expressions? Preferably Perl-style REs, but actually I would be interested to see if anyone has some kind of "regular expression builder" or programming interface for CF, Perl or any RE-capable language. I am not sure what this would look like, but like many of us I have been casually writing REs by hand for the last 8 years and I don't remember ever seeing anything to assist new programmers other than books. thanks for any info, Don ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Regular Expressions - Programming Interface?
That's a tricky one. Wizards and auto-complete tools work best for tasks that are defined and repetetive; RE's in my experience are neither. RE's don't have a rigid syntactical framework like programming languages. By definition you are matching arbitrary strings. I think the best way, albeit tricky, would be to create a natural language tool. What I'm envisioning is something like MS SQL Server's English Language Query engine whereby a user could enter, in "natural" language, the criteria and have the program decipher and convert that into a valid RE. Steve -Original Message- From: Don Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 07, 2000 10:57 AM To: CF-Talk Subject: Regular Expressions - Programming Interface? Per a discussion at last night's CFUG, Is anyone aware of any programming interface that would help new programmers learn to write regular expressions? Preferably Perl-style REs, but actually I would be interested to see if anyone has some kind of "regular expression builder" or programming interface for CF, Perl or any RE-capable language. I am not sure what this would look like, but like many of us I have been casually writing REs by hand for the last 8 years and I don't remember ever seeing anything to assist new programmers other than books. thanks for any info, Don ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Regular Expressions - Programming Interface?
Here is a link to one, although I don't think it is totally 100% Perl compatible. http://www.funduc.com/search_replace_wizard.htm dave At 10:56 AM 12/7/2000 -0500, you wrote: Per a discussion at last night's CFUG, Is anyone aware of any programming interface that would help new programmers learn to write regular expressions? Preferably Perl-style REs, but actually I would be interested to see if anyone has some kind of "regular expression builder" or programming interface for CF, Perl or any RE-capable language. I am not sure what this would look like, but like many of us I have been casually writing REs by hand for the last 8 years and I don't remember ever seeing anything to assist new programmers other than books. thanks for any info, Don ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
[CF-Talk] Re: Regular expressions . . . a good tutorial somewhere?
On the other hand, trying to do things with JavaScript means dealing with a. incompatibilies between various versions of IE b. incompatibilities between various versions of Netscape c. incompatibilities between IE and Netscape d. incompatibilities among the other lesser used GUI based browsers e. incompatibilities among the various non-GUI based web agents - not only lynx, but spiders, page scrapers, etc. I usually recommend people run screaming away from JavaScript, rather than go crazy trying to deal with it... -- Never apply a Star Trek solution to a Babylon 5 problem. Larry W. Virden mailto:[EMAIL PROTECTED] URL: http://www.purl.org/NET/lvirden/ Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. -- -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular expressions
CFSET variables.TextFile = REReplace(variables.TextFile, ",,", ", ,","all") CFSET variables.TextFile = REReplace(variables.TextFile, ",,", ", ,","all") Yeah, I did. And it worked. But I figured it was probably better (in the long run) to ask the "right" way of doing it in 1 RE :-) -- Aidan Whitehall [EMAIL PROTECTED] The Net Profits Internet Services ColdFusion website development, domain names, hosting and tuition Tel: +44 (0) 1695 50050 (North West England) -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular expressions . . . a good tutorial somewhere?
If you can get away with doing it client-side, just use JavaScript. The RegExp implementation is excellent. tom - Original Message - From: "Steve Bernard" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 18, 2000 11:48 AM Subject: RE: Regular expressions . . . a good tutorial somewhere? I have to admit a lack of familiarity with Henry Spenser's library. If it's written in C or C++ I imagine that it could be ported to the CFX API. I am not much of a C++ developer unfortunately. There may be other RegEx engines out there that are implemented as COM objects. This would be a viable solution on Windows boxes. It wouldn't be very efficient to call a command line tool, like 'grep', via CFEXECUTE on a regular basis though. Steve -Original Message- From: Larry W. Virden [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 17, 2000 4:21 AM To: [EMAIL PROTECTED] Subject: Re: Regular expressions . . . a good tutorial somewhere? From: "Steve Bernard" [EMAIL PROTECTED] etc.. Also, be prepared to be frustrated because you'll find some great RegEx features that CF doesn't support because it has a half-ass, third-party RegEx library bundled into it. So what would it take to wrap code around Henry Spenser's regular expression library and turn it into a proper ColdFusion set of tags? -- Never apply a Star Trek solution to a Babylon 5 problem. Larry W. Virden mailto:[EMAIL PROTECTED] URL: http://www.purl.org/NET/lvirden/ Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. -- -- -- -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular expressions . . . a good tutorial somewhere?
From: "Steve Bernard" [EMAIL PROTECTED] etc.. Also, be prepared to be frustrated because you'll find some great RegEx features that CF doesn't support because it has a half-ass, third-party RegEx library bundled into it. So what would it take to wrap code around Henry Spenser's regular expression library and turn it into a proper ColdFusion set of tags? -- Never apply a Star Trek solution to a Babylon 5 problem. Larry W. Virden mailto:[EMAIL PROTECTED] URL: http://www.purl.org/NET/lvirden/ Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. -- -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular expressions
Did you try using it twice? CFSET variables.TextFile = REReplace(variables.TextFile, ",,", ", ,","all") CFSET variables.TextFile = REReplace(variables.TextFile, ",,", ", ,","all") or even CFSET variables.TextFile = REReplace(REReplace(variables.TextFile, ",,", ", ,","all"), ",,", ", ,","all") to make it really confusing tom - Original Message - From: "Aidan Whitehall" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, September 17, 2000 10:35 AM Subject: Regular expressions This regular expression CFSET variables.TextFile = REReplace(variables.TextFile, ",,", ", ,", "all") turns this valuevalue into value, ,, ,value when I want it to be turned into value, , , ,value Can anyone alter it so that it works as needed? Thanks if you can :-) -- Aidan Whitehall [EMAIL PROTECTED] The Net Profits Internet Services ColdFusion website development, domain names, hosting and tuition Tel: +44 (0) 1695 50050 (North West England) -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: Regular expressions . . . a good tutorial somewhere?
O'Reilly has a good book on RegEx's. You'll have to weed through the parts that don't apply though. It has sections dedicated to RegEx's in Perl, Grep, etc.. Also, be prepared to be frustrated because you'll find some great RegEx features that CF doesn't support because it has a half-ass, third-party RegEx library bundled into it. "Mastering Regular Expressions", O'Reilly Press. ISBN #1-56592-257-3 Steve - Original Message - From: "Dan Haley" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 08, 2000 6:37 PM Subject: Regular expressions . . . a good tutorial somewhere? Anyone have a link to a decent tutorial for regex? Can I look at Perl tutorials for this and not be too far off on what to expect from CF? -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: Regular expressions . . . a good tutorial somewhere?
Yes there are just a few pitfalls you have to watch out for some parts of regular expressions do not work in CF. -Original Message- From: Dan Haley [mailto:[EMAIL PROTECTED]] Sent: Friday, September 08, 2000 6:38 PM To: '[EMAIL PROTECTED]' Subject: Regular expressions . . . a good tutorial somewhere? Anyone have a link to a decent tutorial for regex? Can I look at Perl tutorials for this and not be too far off on what to expect from CF? Thanks, Dan -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular expressions . . . a good tutorial somewhere?
Danny Goodman's Javascript Bible has a chapter on regular expressions. Also, the October issue of Web Techniques has a three page article. I haven't played with regular expression and CF, so I can't answer your second question. Regards, Marc Garrett - Original Message - From: "Dan Haley" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 08, 2000 6:37 PM Subject: Regular expressions . . . a good tutorial somewhere? Anyone have a link to a decent tutorial for regex? Can I look at Perl tutorials for this and not be too far off on what to expect from CF? -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: [Regular Expressions]
hi, if this is written in perl try... while !(m/\input//g) David Cummins [EMAIL PROTECTED] wrote: Hi everybody I've got a bit of a problem with regular expressions. We've taken over development of a web site from other developers, and they didn't tell us which templates are scheduled to run automatically. My idea was to look for pages that don't have any user interaction in them, i.e. no input tags. This should be able to be done easily from ColdFusion Studio's extended find. The only problem is, how do you specify the concept of "any file which does not contain this string" in regular expressions? If anybody has any ideas, please let me know. David -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. Get free email and a permanent address at http://www.netaddress.com/?N=1 -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebarRstsbodyRsts/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular Expressions
Sean [Re]Find has an optional 3rd parameter: [Start position]. You can use this to create a loop through the target of the [Re]Find. Dick For Example: CFSET EOL = chr(13) chr(10) CFSET Transformed = "line 1" EOL "line 2" EOL "line 3" EOL "line 4" CFSET LineEndList="" CFSET StartPos = 1 CFSET ThisLineEnd = 1 CFLOOP CONDITION="#ThisLineEnd# NEQ 0" CFSET ThisLineEnd = Find(EOL, Transformed, StartPos) CFIF ThisLineEnd CFSET LineEndList = ListAppend(LineEndList, ThisLineEnd) CFSET StartPos = ThisLineEnd + 1 /CFIF /CFLOOP CFOUTPUT |# Transformed#|BR This is it...#LineEndList# /CFOUTPUT I have a file that I am reading with CFFILE. The variable of which is = "transformed". The following will give me the position of the first line break. cfset firstline =3D #REFind("#chr(13)##chr(10)#", transformed)# How would I find the position of all line breaks if I did not know how = many lines a file was going to have? -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: Regular Expressions
I've been reading O'Reilly's "Mastering Regular Expressions" (haven't quite finished) and to my understanding using [^] is only for single characters. Using ^ outside a character class (meaning the [] format) means "match the start of a line." If you can be reasonably certain, by having a familiarity with your data, that your inside sting will not include a "", you will be able to use: REFind("!-- snip --[^]!-- /snip --", file) but again, if there are any 's between those snips you'll have to find another way. Maybe when I finish the book I'll know a good way to figure this sort of thing out. Danny Zigrino [EMAIL PROTECTED] -Original Message- From: Jonathan McGuire [mailto:[EMAIL PROTECTED]] Sent: Monday, May 01, 2000 9:42 AM To: [EMAIL PROTECTED] Subject: Re: Regular Expressions Try this (untested, but should be darn close): REFind("!-- snip --^(!-- /snip --)!-- /snip --", file) In the first one you tried, must realize that regexp are by default "hungry". They will match on the largest match possible. In your case this meant that the regexp was matching the first opening tag all the way to the last closing tage due to the ".*". In your second one you were much closer but "[^!-- /snip --]" means to match any of the following: not "" or ! or - or / or s or n, etc. Try it with parens as above to say "not this pattern". Jonathan McGuire - Original Message - From: "Oblio Leitch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 30, 2000 4:02 PM Subject: Regular Expressions I'm having trouble and I was hoping someone can help me. Senario: I have a page that I'm trying to extract pieces from. To mark the section I'm trying to edit, I've place !-- snip -- and !-- /snip -- around the section. Next, I'm opening the file (CFFILE) and doing a regular expression to find that section: REFindNoCase("!-- snip --.*!-- /snip --", file). Works great. Now, to make several places on the page editable, I placed several snips. Now the regular expression only finds the first open snip and the last close snip, including all the others inside. Question: How do I find just those sections? I thought about doing REFindNoCase("!-- snip --[^!-- /snip --]*", file), but that doesn't work - it excludes all the characters instead of the whole string. Is there a way to exclude a complete string instead of just a group of characters? Any suggestions would be most helpful. Any example would be great too. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Regular Expressions
Thank you for your prompt response, however, what you suggest doesn't work. The problem with what you suggest is, according to the CF manual, the caret in front of a string means "the matched string must be at the beginning of the string being searched". In order to exclude the string, it must be in brackets, ([]), but then it tries to exclude the parentheses. The more I play with different strings, the more I'm convinced that you cannot exclude as specific string - only characters. I don't know if this is a short-coming of CF or of regular expressions in general. Thanks for try'n. Oblio At 5/1/00 09:41 AM, you wrote: Try this (untested, but should be darn close): REFind("!-- snip --^(!-- /snip --)!-- /snip --", file) In the first one you tried, must realize that regexp are by default "hungry". They will match on the largest match possible. In your case this meant that the regexp was matching the first opening tag all the way to the last closing tage due to the ".*". In your second one you were much closer but "[^!-- /snip --]" means to match any of the following: not "" or ! or - or / or s or n, etc. Try it with parens as above to say "not this pattern". Jonathan McGuire - Original Message - From: "Oblio Leitch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 30, 2000 4:02 PM Subject: Regular Expressions I'm having trouble and I was hoping someone can help me. Senario: I have a page that I'm trying to extract pieces from. To mark the section I'm trying to edit, I've place !-- snip -- and !-- /snip -- around the section. Next, I'm opening the file (CFFILE) and doing a regular expression to find that section: REFindNoCase("!-- snip --.*!-- /snip --", file). Works great. Now, to make several places on the page editable, I placed several snips. Now the regular expression only finds the first open snip and the last close snip, including all the others inside. Question: How do I find just those sections? I thought about doing REFindNoCase("!-- snip --[^!-- /snip --]*", file), but that doesn't work - it excludes all the characters instead of the whole string. Is there a way to exclude a complete string instead of just a group of characters? Any suggestions would be most helpful. Any example would be great too. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: Regular Expressions
Can you confirm that you can only exclude single characters and not whole strings? I would think you should be able to set a string using parentheses, but when I do, the parentheses lose their "special character" status. Is there any way to regain it or recreate it? Oblio At 5/1/00 09:51 AM, you wrote: I've been reading O'Reilly's "Mastering Regular Expressions" (haven't quite finished) and to my understanding using [^] is only for single characters. Using ^ outside a character class (meaning the [] format) means "match the start of a line." If you can be reasonably certain, by having a familiarity with your data, that your inside sting will not include a "", you will be able to use: REFind("!-- snip --[^]!-- /snip --", file) but again, if there are any 's between those snips you'll have to find another way. Maybe when I finish the book I'll know a good way to figure this sort of thing out. Danny Zigrino [EMAIL PROTECTED] -Original Message- From: Jonathan McGuire [mailto:[EMAIL PROTECTED]] Sent: Monday, May 01, 2000 9:42 AM To: [EMAIL PROTECTED] Subject: Re: Regular Expressions Try this (untested, but should be darn close): REFind("!-- snip --^(!-- /snip --)!-- /snip --", file) In the first one you tried, must realize that regexp are by default "hungry". They will match on the largest match possible. In your case this meant that the regexp was matching the first opening tag all the way to the last closing tage due to the ".*". In your second one you were much closer but "[^!-- /snip --]" means to match any of the following: not "" or ! or - or / or s or n, etc. Try it with parens as above to say "not this pattern". Jonathan McGuire - Original Message - From: "Oblio Leitch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 30, 2000 4:02 PM Subject: Regular Expressions I'm having trouble and I was hoping someone can help me. Senario: I have a page that I'm trying to extract pieces from. To mark the section I'm trying to edit, I've place !-- snip -- and !-- /snip -- around the section. Next, I'm opening the file (CFFILE) and doing a regular expression to find that section: REFindNoCase("!-- snip --.*!-- /snip --", file). Works great. Now, to make several places on the page editable, I placed several snips. Now the regular expression only finds the first open snip and the last close snip, including all the others inside. Question: How do I find just those sections? I thought about doing REFindNoCase("!-- snip --[^!-- /snip --]*", file), but that doesn't work - it excludes all the characters instead of the whole string. Is there a way to exclude a complete string instead of just a group of characters? Any suggestions would be most helpful. Any example would be great too. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: Regular Expressions
Character classes and negated character classes [], [^] often change the meaning of what the contents mean. While not an expert, I have learned that character classes are for one character at a time. I think what Howard Owens suggested in the previous response suggests a good work around: cfset inStart=FindNoCase("!-- snip --", scope.infile, 1) cfset inEnd=FindNoCase("!-- /snip --", scope.infile, 1) cfset outContent=Mid(scope.infile, inStart, inEnd-inStart) cfoutput #outContent# /cfoutput Furthermore, if you combined this type of search with a variable to keep track of where you have already searched (in place of the 1), you could convert this to a loop that would search globally for all instances. -Original Message- From: Oblio Leitch [mailto:[EMAIL PROTECTED]] Sent: Monday, May 01, 2000 1:13 PM To: [EMAIL PROTECTED] Subject: RE: Regular Expressions Can you confirm that you can only exclude single characters and not whole strings? I would think you should be able to set a string using parentheses, but when I do, the parentheses lose their "special character" status. Is there any way to regain it or recreate it? Oblio At 5/1/00 09:51 AM, you wrote: I've been reading O'Reilly's "Mastering Regular Expressions" (haven't quite finished) and to my understanding using [^] is only for single characters. Using ^ outside a character class (meaning the [] format) means "match the start of a line." If you can be reasonably certain, by having a familiarity with your data, that your inside sting will not include a "", you will be able to use: REFind("!-- snip --[^]!-- /snip --", file) but again, if there are any 's between those snips you'll have to find another way. Maybe when I finish the book I'll know a good way to figure this sort of thing out. Danny Zigrino [EMAIL PROTECTED] -Original Message- From: Jonathan McGuire [mailto:[EMAIL PROTECTED]] Sent: Monday, May 01, 2000 9:42 AM To: [EMAIL PROTECTED] Subject: Re: Regular Expressions Try this (untested, but should be darn close): REFind("!-- snip --^(!-- /snip --)!-- /snip --", file) In the first one you tried, must realize that regexp are by default "hungry". They will match on the largest match possible. In your case this meant that the regexp was matching the first opening tag all the way to the last closing tage due to the ".*". In your second one you were much closer but "[^!-- /snip --]" means to match any of the following: not "" or ! or - or / or s or n, etc. Try it with parens as above to say "not this pattern". Jonathan McGuire - Original Message - From: "Oblio Leitch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 30, 2000 4:02 PM Subject: Regular Expressions I'm having trouble and I was hoping someone can help me. Senario: I have a page that I'm trying to extract pieces from. To mark the section I'm trying to edit, I've place !-- snip -- and !-- /snip -- around the section. Next, I'm opening the file (CFFILE) and doing a regular expression to find that section: REFindNoCase("!-- snip --.*!-- /snip --", file). Works great. Now, to make several places on the page editable, I placed several snips. Now the regular expression only finds the first open snip and the last close snip, including all the others inside. Question: How do I find just those sections? I thought about doing REFindNoCase("!-- snip --[^!-- /snip --]*", file), but that doesn't work - it excludes all the characters instead of the whole string. Is there a way to exclude a complete string instead of just a group of characters? Any suggestions would be most helpful. Any example would be great too. --- - -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. --- - -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. --- --- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -
RE: Regular Expressions Trouble
-Original Message- From: Dick Applebaum [SMTP:[EMAIL PROTECTED]] Sent: Monday, March 27, 2000 1:33 AM To: [EMAIL PROTECTED] Subject: Re: Regular Expressions Trouble It works for me on CF 4.0 [snip] At 9:11 PM -0800 3/26/2000, [EMAIL PROTECTED] wrote: Hi; I'm having trouble figuring out why some of my regular expressions don't work in CF 4.5. For example, say that I've read the HTML content of a Web page into a string variable and now I want to perform a search and replace on that variable. For simplicity's sake, let's say that I want to get rid of everything between and including the HEAD tags. In Perl, etc., the expression that would identify this text would be something like: HEAD.*/HEAD That is, a head tag followed by any character, followed by one or more of those "any" characters, until a closing head tag is reached. (This assumes that my Perl script has been designed to examine the whole variable at once, rather than line by line--CF does this by default, according to its docs). But when I try a line like the following in CF, the regular expression parser returns an error: CFSET my_string = REreplacenocase(mystring, "HEAD.*/HEAD", "") There's bigger regex experts out there than me, but I share what I've discovered. Yes, it works in 4.0, but not 4.5. I've had regexs break on me since the upgrade because of the difference. The ( .*) no longer works in 4.5. This appears to be an undocumented feature. I _think_ this has something to do with the limit on the number of characters any reg ex can find in CF. Probably, what you have to do is something like (this is off the top of my head, untested code and is intended merely as a pointer): cfset start_string=REreplacenocase(mystring, "HEAD","") cfset end_string=REreplacenocase(mystring, "HEAD", "") cfset newstring=Mid(mystring, start_string, end_string-start_string) H. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.