0

I am not at all experienced with regex, so please bear with me.

I am building a simple content markup language for an admin.

I want for the admin user to be able to create a link by specifying the following within an admin;

[link="http://www.google.com"]Google[/link]

From this, I need to basically get the value XXX in [link="XXX"] and the value between [link="abcd"]XXX[/link]. So for the above example I'd want to extract 'http://www.google.com' and 'Google'.

I am working with PHP.

Any help would be greatly appreciated.

0

1 Answer 1

0

you can use preg_match like this

$url = '[link="http://www.google.com"]Google[/link]';   
preg_match('/\[link=\"(.+?)\"\](.+?)\[\/link\]/', $url, $matches);
print_r($matches);

$matches will contain

Array
(
    [0] => [link="http://www.google.com"]Google[/link]
    [1] => http://www.google.com
    [2] => Google
)
Sign up to request clarification or add additional context in comments.

1 Comment

glad i could help. have a nice day. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.