Welcome to WebmasterWorld Guest from 184.72.177.182

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Dreamweaver Regular Expression Help

[*]?

     
6:39 pm on Sep 8, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 7, 2006
posts:94
votes: 0


Hello everyone,

I have many codes I'm trying to search + replace. Here's an example:

<A href="http://www.fruits.net/click-1963151-10399388" target=_blank>Fruits are good</A>* - Fruits are healthy and good for you.<IMG height=1 src="http://www.banana.com/image-1963151-10399388" width=1 border=0>

I want to search for everything between

<IMG height=1 src="http://www.banana.com/image-1963151-10399388" width=1 border=0>

so I went to dreamweaver and searched this:

<A href="http://www.fruits.net/click-1963151-10399388" target=_blank>Fruits are good</A>* - Fruits are healthy and good for you.<

  • >

    I thought the regular expression

  • would find everything between < >?

    I'd appreciate any help!

  • 6:45 pm on Sept 8, 2006 (gmt 0)

    Junior Member

    10+ Year Member

    joined:Jan 7, 2006
    posts:94
    votes: 0


    Hmm .. looks like forum codes messed the characters.

    Here it is again, with added spaces [ * ]

    <A href="http://www.fruits.net/click-1963151-10399388" target=_blank>Fruits are good</A>* - Fruits are healthy and good for you.<[ * ]>

    12:10 am on Sept 9, 2006 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member jtara is a WebmasterWorld Top Contributor of All Time 10+ Year Member

    joined:Nov 26, 2005
    posts:3041
    votes: 0


    I'm not familiar specifically with Dreamweaver regular expressions. However, I did a quick search, and they seem to follow the conventions of Unix regular expressions.

    It's hard to tell just what you wrote, due to the reformatting. However, I assume you used .* to match everything inside the IMG tag.

    . matches "any character". * says match 0 or more of the previous character (e.g. "any character").

    The problem is that * is "greedy". It wants to match the LONGEST string possible. So, it would match everything up to the LAST ">" in your file!

    Instead of .* you need to use (hope this comes out...):

    [^>]*

    This says match a string of 0 or more of any character other than >. So, the match will stop just before the first >, rather than the last >.