preg_replace question

Discussion in 'PHP' started by Anteros, Aug 20, 2007.

  1. #1
    Hi, I'm doing a quick modification to an existing script and I don't understand too much how wildcards work in PHP so I'm a bit stalled trying to do a preg_replace.

    What I need to do is replace something like

    <tag asadsadasd>
    word1 adasdadsadas word2 adasdasd
    asdasddasd = word3
    aasdassadas
    </tag>

    but replacing the words found within that portion of text without going into multiple iterations of preg_replace for each word.

    I've found some examples but they don't explain when to use / [ and other special characters for doing wildcards.

    Thanks for your help =)
     
    Anteros, Aug 20, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    This seems to be a sample text. Can you maybe post a real example? And also, do you just want to replace "word1", "word2", "word3"? Or all text between the tags?
     
    nico_swd, Aug 21, 2007 IP
    Anteros likes this.
  3. Anteros

    Anteros Peon

    Messages:
    631
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, last night I spent some time researching about regular expressions and I'm getting the grip of it.

    Thanks for your help ;)
     
    Anteros, Aug 21, 2007 IP