user3745594 user3745594 - 1 year ago 99
PHP Question

PHP Regex to get a name from a url tag

There is a lot of Regex to get links or a value from url tags

<a href
, but what about extract a value from url tags like this

$text = '[URL=""]ANY THING[/URL]';

if i want get value
from this url tag , what Regex Can I use ?

Answer Source

You can use this one


But you should probably learn Why.. Here is a good tester that shows that regx at work

Traditionally this is called BBcode ( builtin board code )

There are full PHP implementations of this sort of thing you can use besides regx

If you want both ( optionally the url ) you can use this one


And here is that one at work

That last one does require the " around URL, I have seen them done with ' or no quotes at all.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download