![]() |
help with a regular expression please
Say I have a string:
x!!x bbbbbdddd x!!x bbbbaaaaddddd x!!x bbbbcccccddddd How do I match the bbbb(.*)dddd that do NOT have an "x!!x" substring between them? Don't ask what for, just tell me how do to such regex. explode() is not an option for my purposes. Thanks. Ideally, it would be something like ([^x!!x]*), but that won't work for some reason. |
lookahead/lookbehind assertions
|
Example plz?
|
> x!!x bbbbbdddd x!!x bbbbaaaaddddd x!!x bbbbcccccddddd
From this string, what would be your desired match(es)? |
Hmm..
I just want to end up having bbbb moved as towards the closest ddddd, so that the result would be: x!!x bbbbdddd x!!x aaaabbbbddddd x!!x cccccbbbbddddd EDIT: Actually, nevermind. That won't work as desired because the corresponding bbbb and dddd could have inner pairs of x!!x between them, which would give an undesired result. So nvm... :P |
PHP Code:
|
Yes, that works. However, as I said, it could happen like.. let me explain.
<bbbb <bbbbaaaadddd> dddd> So here, my result would have to be: < <aaaabbbbdddd> bbbbdddd> However, because there is another <....> inside the outer <....>, there is no way to see the the first bbbb belongs to the latest dddd. Or is there? :P |
<Disclaimer>
This Code is utterly bad </Disclaimer> PHP Code:
|
Why is it utterly bad? Because of performance?
|
Because it is recursive and not checked ;)
|
All times are GMT. The time now is 03:15 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|