Welcome to WebmasterWorld Guest from 54.166.224.46

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Dreamweaver Regular Expression Help

[*]?

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

5+ Year Member



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 Sep 8, 2006 (gmt 0)

    5+ Year Member



    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 Sep 9, 2006 (gmt 0)

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



    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 >.

     

    Featured Threads

    Hot Threads This Week

    Hot Threads This Month