House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  Regular Expressions (RegEx)

Convert string to html file name

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

Convert string to html file name

Yeah, sorry about that. The function is fine. It had something to do with Cantrell, Adam 11/13/2003 04:09 PM
I can't see why it would do that. The apostrophes are removed with a simple Pascal Peters 11/13/2003 02:12 PM
Great timing on this. I was trying to do something similar this morning, Cantrell, Adam 11/13/2003 12:40 PM
As I said, I didn't test. I wrote it from home during a holiday. Ben is Pascal Peters 11/13/2003 03:33 AM
That got it! DougF 11/12/2003 03:27 PM
Try breaking the line Ben Doom 11/12/2003 02:55 PM
Thanks Peter, DougF 11/12/2003 02:38 PM

11/13/2003 04:09 PM
Author: Cantrell, Adam Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#667 Yeah, sorry about that. The function is fine. It had something to do with the way I was processing the XML I was pulling the string out of. Thanks again. Adam. I can't see why it would do that. The apostrophes are removed with a simple replace, not by a regexp. Have you tried taking ou the line to see what happens? If you don't find a solution, I will try to debug this tomorow morning (when I've got the server running) Pascal -----Oorspronkelijk bericht----- Van: Cantrell, Adam [mailto:Acantrell@kentlaw.edu] Verzonden: do 13/11/2003 18:37 Aan: CF-RegEx CC: Onderwerp: RE: Convert string to html file name Great timing on this. I was trying to do something similar this morning, then opened up this list and here's the answer. But does anyone get an error running this on a string with multiple apostrophes? I'm using MX. Adam's File Name (works fine). Adam's Tester's File Name ('Error Occurred While Processing Request' - no description of the error in the debug) Adam. That got it! thanks, DougF -------------- Final solution: -------------- function HTMLFileName(str){ // replace leading and trailing characters str = rereplace(str,"^[^[:alnum:]]*", ""); // remove trailing non-alphanumeric characters str = rereplace(str,"[^[:alnum:]]*$", ""); // remove apostrophies str = Replace(str,"'","","ALL"); // replace groups of non alphanumerical with dashes str = REReplace(str,"[^[:alnum:]]+","-","ALL"); // to lower case str = LCase(str)& ".html"; return str; } #HTMLFileName("#string#")# ----- Excess quoted text cut - see Original Post for more -----   _____  
11/13/2003 02:12 PM
Author: Pascal Peters Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#666 I can't see why it would do that. The apostrophes are removed with a simple replace, not by a regexp. Have you tried taking ou the line to see what happens? If you don't find a solution, I will try to debug this tomorow morning (when I've got the server running) Pascal   -----Oorspronkelijk bericht-----   Van: Cantrell, Adam [mailto:Acantrell@kentlaw.edu]   Verzonden: do 13/11/2003 18:37   Aan: CF-RegEx   CC:   Onderwerp: RE: Convert string to html file name         Great timing on this. I was trying to do something similar this morning,   then opened up this list and here's the answer.      But does anyone get an error running this on a string with multiple   apostrophes? I'm using MX.      Adam's File Name (works fine).   Adam's Tester's File Name ('Error Occurred While Processing Request' - no   description of the error in the debug)      Adam.        Sent: Wednesday, November 12, 2003 2:24 PM   To: CF-RegEx   Subject: Re: Convert string to html file name      That got it!   thanks,   DougF   --------------   Final solution:   --------------   function HTMLFileName(str){   // replace leading and trailing characters   str = rereplace(str,"^[^[:alnum:]]*", "");   // remove trailing non-alphanumeric characters   str = rereplace(str,"[^[:alnum:]]*$", "");   // remove apostrophies   str = Replace(str,"'","","ALL");   // replace groups of non alphanumerical with dashes   str = REReplace(str,"[^[:alnum:]]+","-","ALL");   // to lower case   str = LCase(str)& ".html";   return str;   }   #HTMLFileName("#string#")#     To: "CF-RegEx" <RegEx@houseoffusion.com>   Sent: Wednesday, November 12, 2003 11:52 AM   Subject: Re: Convert string to html file name      > Try breaking the line   > str = REReplace(str,"^[^[:alnum:]]*(.*)[^[:alnum:]]*$","\1");   > into   > str = rereplace(str, "^[^[:alnum:]]*", "");   > str = rereplace(str, "[^[:alnum:]]*$", "");   >   > It's the ever-present greedy match problem from CF5.  :-)   >   > --Ben Doom         _____     
11/13/2003 12:40 PM
Author: Cantrell, Adam Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#665 Great timing on this. I was trying to do something similar this morning, then opened up this list and here's the answer. But does anyone get an error running this on a string with multiple apostrophes? I'm using MX. Adam's File Name (works fine). Adam's Tester's File Name ('Error Occurred While Processing Request' - no description of the error in the debug) Adam. That got it! thanks, DougF -------------- Final solution: -------------- function HTMLFileName(str){ // replace leading and trailing characters str = rereplace(str,"^[^[:alnum:]]*", ""); // remove trailing non-alphanumeric characters str = rereplace(str,"[^[:alnum:]]*$", ""); // remove apostrophies str = Replace(str,"'","","ALL"); // replace groups of non alphanumerical with dashes str = REReplace(str,"[^[:alnum:]]+","-","ALL"); // to lower case str = LCase(str)& ".html"; return str; } #HTMLFileName("#string#")# ----- Excess quoted text cut - see Original Post for more -----
11/13/2003 03:33 AM
Author: Pascal Peters Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#664 As I said, I didn't test. I wrote it from home during a holiday. Ben is right. This is also the reason why, in my opinion, you can't do it in one run. I don't think you can remove leading and trailing characters AND replace the others with - Pascal Try breaking the line str = REReplace(str,"^[^[:alnum:]]*(.*)[^[:alnum:]]*$","\1"); into str = rereplace(str, "^[^[:alnum:]]*", ""); str = rereplace(str, "[^[:alnum:]]*$", ""); It's the ever-present greedy match problem from CF5.  :-) --Ben Doom DougF wrote:
11/12/2003 03:27 PM
Author: DougF Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#662 That got it! thanks, DougF -------------- Final solution: -------------- function HTMLFileName(str){ // replace leading and trailing characters str = rereplace(str,"^[^[:alnum:]]*", ""); // remove trailing non-alphanumeric characters str = rereplace(str,"[^[:alnum:]]*$", ""); // remove apostrophies str = Replace(str,"'","","ALL"); // replace groups of non alphanumerical with dashes str = REReplace(str,"[^[:alnum:]]+","-","ALL"); // to lower case str = LCase(str)& ".html"; return str; } #HTMLFileName("#string#")# ----- Excess quoted text cut - see Original Post for more -----
11/12/2003 02:55 PM
Author: Ben Doom Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#660 Try breaking the line str = REReplace(str,"^[^[:alnum:]]*(.*)[^[:alnum:]]*$","\1"); into str = rereplace(str, "^[^[:alnum:]]*", ""); str = rereplace(str, "[^[:alnum:]]*$", ""); It's the ever-present greedy match problem from CF5.  :-) --Ben Doom DougF wrote: ----- Excess quoted text cut - see Original Post for more -----
11/12/2003 02:38 PM
Author: DougF Short Link: http://www.houseoffusion.com/groups/regex/thread.cfm/threadid:118#659 Thanks Peter, Works great except when the string has any number of trailing non-alphanumeric characters. Adds a dash to the end of the string. Should have said '-remove any leading or trailing non-alphanumeric characters' instead of  '-return string with both leading and trailing spaces removed'. e.g. [yellow!] results in [yellow-} e.g. [yellow !} results in [yellow-} Any suggestions? DougF ----- Excess quoted text cut - see Original Post for more ----- doesn't quite catch everything. ----- Excess quoted text cut - see Original Post for more ----- (bens)], > -remove all non-alphanumeric and punctuation characters, > -replace single or multiple spaces with a single dash [eg. (white rose) becomes (white-rose)]. > -replace a punctuation character with a fore and aft by space with a single dash with no spaces [eg. (ben & jerry) becomes (ben-jerry)].
<< Previous Thread Today's Threads Next Thread >>

Search regex

May 25, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference