Skip to main content
Known Participant
August 18, 2008
Question

Regular expression

  • August 18, 2008
  • 1 reply
  • 378 views
<cfset ny="amar, powar">
<cfset indi=REReplaceNoCase("my <name> is <amar>","</?(#ListChangeDelims(ny,"|")#)[^ >]*>","","ALL" )>
<cfoutput><br>"ind1 " #indi# <br></cfoutput>

Output of above code is " my is"

Why it is replacing "<name>" even it isn't present in lis?

Thanks




    This topic has been closed for replies.

    1 reply

    Inspiring
    August 18, 2008
    because the browser thinks those angle brackets indicate an html tag. cfdump your variable to troubleshoot your code.
    Known Participant
    August 18, 2008
    thank you sir.

    what is meaning of "/?" at beginnging of pattern ?

    Thanks
    amar
    Inspiring
    August 18, 2008
    The ? means that the character or group preceding it is optional or more correctly means that there can be one or none of them. It can also be used to signify that a match should not be greedy but it is not being used in this case. I suggest getting a book on Regex. It is essentially quite straight forward once you know the syntax but it is very powerful and if you are doing any string manipulation it is a must to know well!