It works for me on CF 4.0


The snippet:
The snippet:

     <cfset mystring ="
     <html>
     some preceeding
     lines to be retained<head>this is the target
     head section to be removed
     </head><body>... some following
     lines to be retained... and so on
     ">
    
    
     <cfoutput>
     <br> <br> mystring,...|#mystring#|...
     <br><br>
     </cfoutput>

     <CFSET my_string = REreplacenocase(mystring, "<HEAD>.*</HEAD>", "")>

     <cfoutput>
     <br> <br> my_string...|#my_string#|...
     <br><br>
     </cfoutput>

Gives (source):

     <br> <br> mystring,...|
     <html>
     some preceeding
     lines to be retained<head>this is the target
     head section to be removed
     </head><body>... some following
     lines to be retained... and so on
     |...
     <br><br>



     <br> <br> my_string...|
     <html>
     some preceeding
     lines to be retained<body>... some following
     lines to be retained... and so on
     |...
     <br><br>


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>", "")>
>
>I thought it might be because the brackets or backslashes are
>reserved characters, but the CF docs say they aren't. To test this, I
>tried:
>
><CFSET my_string = REreplacenocase(mystring, "<HEAD>.*", "")>
>
>Which behaved as expected and removed everthing in the string
>from the HEAD tag on (including the HEAD tag itself).
>
>Apparently any time you add an end boundary to the expression,
>ColdFusion chokes.
>
>Am I misunderstanding something, or is this a deficiency in CF's
>regular expression parser? If so, does anyone know of a
>workaround?
>
>Thanks,
>
>Melinda
>
>
>------------------------------------------------------------------------------
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit 
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_tal 
>k 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=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to