The Arcive of vBulletin Modifications Site. |
|
Combining 2 preg_replace statements Details »»
|
|||||||||||||||||||||||||
Can someone please tell me how I can combine to 2 following statements into one? I need to parse both of them out of the same code but they seem to cancel each other out.
PHP Code:
PHP Code:
Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
||||
|
||||
|
The problem with regex is that you can match patterns with it, but you can't count with them.
![]() The following pattern will do the match: ((.*)*(\[you\])*)* The problem is that due to the repeating nature of the pattern and the fact that it has sub patterns you can not code a replacement for it. ![]() You may be stuck with the 2 regex's... |
|
#3
|
||||
|
||||
|
I don't mind doing 2, but they cancel each other out. One will work, but not the other. Whichever one comes last seems to work. How do I make then both work?
|
|
#4
|
||||
|
||||
|
You said this would do the match. Is this how it should look (with the siU)?
PHP Code:
|
|
#5
|
||||
|
||||
|
Not sure if I am being picky here but in the second preg_replace you should change the regex
from "/(\[)(you)(])/siU" to "/(\[)(you)(\])/siU" I don't see why they would cancel each other out...
|
|
#6
|
||||
|
||||
|
Quote:
What I meant was that the regex I gave would replace the (.*) in the first preg_replace and would try to match both patterns in your statements. But since the replacements need to be done in 2 passes, it is of no help... |
|
#7
|
||||
|
||||
|
Quote:
|
![]() |
|
|