SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need regular expression for replace operation

    Hi, I'd like to use a search and replace operation to clean up some old code I'm no longer using. I have a folder with hundreds of articles/files, with the first letter in the first paragraph of each article surrounded by a span, like this:

    <p class="pfirst"><span class="dropcap">T</span>his is the first letter in the first paragraph of this article.</p>
    Can someone show me a regex I can use to remove all instances of that <span></span>? Thanks.

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using a program like Dreamweaver or GoLive, you can do a simple find and replace and have the application search through the entire site.

    By hand however, that's another animal entirely.

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, I didn't even realize Dreamweaver had a regex search and replace feature. Unfortunately, it doesn't work - at least not by simply typing in <span class="dropcap"></span> when there are various letters inside the span. It says "not found."

    There should be a simple regex function that I can paste in which will zap all these spans. I remember doing something similar for paragraph tags a long time ago, but I can't remember what the regex code was. Anyone?

  4. #4
    SitePoint Member
    Join Date
    Feb 2006
    Location
    Miami
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...input in
    Find textbox:
    Code:
    <span class="dropcap">(.+?)</span>
    Replace textbox:
    Code:
    $1

  5. #5
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that worked like a charm.


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
  •