homepage Welcome to WebmasterWorld Guest from 54.211.157.103
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Dreamweaver Regular Expression Help
[*]?
yummybanas




msg:3076621
 6:39 pm on Sep 8, 2006 (gmt 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!

  •  

    yummybanas




    msg:3076626
     6:45 pm on Sep 8, 2006 (gmt 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.<[ * ]>

    jtara




    msg:3076865
     12:10 am on Sep 9, 2006 (gmt 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 >.

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / WebmasterWorld / New To Web Development
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved