Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Find spaces in side A Tag

Last post 11-20-2009, 6:05 PM by Tylerreplogle. 1 replies.
Sort Posts: Previous Next
  •  11-20-2009, 2:49 PM 57427

    Find spaces in side A Tag

    Hey,

    I'm trying to find all spaces in an a tag and replace with with %20. This is what i have so far.

    (href\s*=\s*"[^"]*)(\x20)([^"]*")

    It works just fine when all i'm trying to do is replace any space. However inside some of these a tags are asp tags. They look something like this
    href="/<% Response.Write("somethingHere") %>"

    The Regex sees the space in between the tag and the statement puts it up on the results.

     I was wondering if any one could construct an regex for dreamweaver that will ignore the spaces in side the asp tags.

     

    Thank you,

     

    Tyler

  •  11-20-2009, 6:05 PM 57429 in reply to 57427

    Re: Find spaces in side A Tag

    I found a fix my self

    i just added < to the [^"] so it looks like this

    (href\s*=\s*"[^"]*)(\x20)([^"]*")

    then i found out that javascript in side the href was a problem

    so i added : too the [^] and so it looks like this

    (href\s*=\s*"[^:"]*)(\x20)([^"]*")

    Theres a problem with that though because sometimes you have links like "http://" or "https" so i had to hand pick those but doing it this way saved me tons.

     

View as RSS news feed in XML