SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reg Exp DW Find and Replace

    Hi all,

    Can some one tell me how I can target saveFav in DW Find and Replace using a regular expression:

    Here's what I have:
    class="saveFav iconS"

    I need to target saveFav inside the class.

    I would like for it to change to:
    class="iSaveFav iconS"

    Thanks!

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any reason for the regex versus just simple class="saveFav out of curiosity? If it's quotation, I'd just do one for double, then one for single rather than trying to feed DW a regex (yes, I hate doing regexes that much ).

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because I am going to be searching on mulitiple files and what if I have:

    class="iconS saveFav save"

    searching for:

    class="saveFav iconS

    won't target that saveFav inside of the class attribute.

    Thanks!

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh okay that makes more sense. Let's try...

    Code:
    class="(.*?)saveFav([^"]+)
    I'm not sure what DW uses for converting the grouping matches to variables in the replace section, but that will basically group what's before and after savFav.

    It's untested as I don't have dreamweaver on me, so best to backup the file and do the operation on a single file in case there's something weird with it.

    Let me know if that works.

  5. #5
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works on this:
    class="saveFav iconS"

    but not this:
    class="iconS saveFav"

    Thanks for trying

  6. #6
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, the + (must have at least 1 match) would be the reason why.. let's try:

    Code:
    class="(.*?)saveFav([^"]*)
    if that doesn't work:

    Code:
    class="(.*?)saveFav([^"]*?)
    if that doesn't work.. well .. I guess I'll go cry or something.

  7. #7
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a bunch!

    Works like a charm!

    Thanks again

  8. #8
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yay! Now to go wash my brain out and pretend I never wrote that!

    Oh well, before I do:

    Code:
    class="(.*?)saveFav([^"]*)
    match class="
    Then capture 0 or more of all characters in a non-greedy style (so it doesn't potentially grab saveFav too, nullfying your search)
    Then capture 0 or more characters which are not " (everything up to the quote)

    That about sums up what that means. Okay, now where'd I put the bar of soap...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •