Not (bracket) problem

exess

New member
Joined
Jan 3, 2005
Messages
1
Hi all,

Ive got quite a tricky one here. Heres the deal:

search : \[(url|URL)\](.*)\[/(url|URL)\]
replace : <a href="(\1)">...</a>

Problem is: when performing it in php sith ereg_replace(), it simply replaces everything between the first occurrence of "[ url ]" and the last one of "[ /url ]" i.e. if there are more than one pseudo-url in the string, it messes up (spaces are added in the quotes for pseudocode reasons).

Side note: when using my text editor, it doesnt mess up. Life is bitter...

What Im looking for: a way to replace my wildcard (.*) with a "not bracket" expression. It succeeded in my text editor

search1: \[(url|URL)\]([^\]]*)\[/(url|URL)\]

but unfortunately not in PHP and I dont know why. I know PHP uses the Posix regexp mechanism. This is wild, Id appreciate some help... ;)
 
This forum is for Microsoft .NET

Hi exess,

The first thing you should know is that this forum is for discussing the Microsoft .NET development environment, and that this regular expression subforum is for discussing regexs as pertains to .NET.

The second thing is that your search string above:

exess said:
search : \[(url|URL)\](.*)\[/(url|URL)\]
replace : <a href="(\1)">...</a>

looks good from my regex experience, which doesnt include php. Your replacement string looks good, also. Now, you may have problems, like you said, if there are occurrences of [/url] before the actual end of your string. The best thing to do is to find a forum for discussing php programming, where folks know about php regular expressions.

Happy regexing! :)
 
Back
Top