Jump to content

preg_replace patterns

- - - - -

  • Please log in to reply
No replies to this topic

#1
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hi there,

Having trouble with the preg_replace function not working for multiple lines, like this pattern:

\[h([1-6])\](.*)\[\/h([1-6])\]
</SPAN>

does NOT work for:

[h1]test
[/h1]

but DOES work for:

[h1]test  [/h1]

How can I make it apply for ALL lines instead of only on same line?

Thanks in advanced!

Cheers.

EDIT: stupid question, solved :D Had to use the 's' qualifier to make it apply for ALL lines.

Though got new question: how can I require inside a pattern, the same input to be repeated, like:

/\[h([1-6])\](.*)\[\/h([1-6])\]/is

matches:

Quote

[h1]test[/h1]

but also

Quote

[h1]test[/h6]

but I only want it to match the first example, or would I then end up with multiple patterns ( for all 1 through 6 seperated patterns? ) because I think there should be a more efficient way isn't there?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users