SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Any regex whizzes out there?

    Could someone tell me how to make this into a preg_replace statement:

    I want to replace this:
    Code:
    <p><strong>...anytext...</strong></p>
    or this:
    Code:
    <p>   <strong>...anytext...</strong></p>
    or this:
    Code:
    <p><strong>...anytext...</strong>  </p>
    With this:
    Code:
    <h4>...anytext...</h4>
    Thanks in advance
    Matt Alexander
    Alexander Site Design

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $p '#<p>\s*<strong>(.*?)</strong>\s*</p>#si';
    echo 
    preg_replace($p'<h4>\1</h4>'$text); 

  3. #3
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're the wind beneath my wings, clamcrusher ;-)
    Matt Alexander
    Alexander Site Design

  4. #4
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really have to sit down one of these days and commit all of the regex ins and outs to memory. It would save me so much time and code. I appreciate the help.
    Matt Alexander
    Alexander Site Design


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
  •