Nils R.
Nils R.

Reputation: 1

Regex to replace PHPbb url to HTML

I'm trying to search and replace URL's coming from a PHPbb dump into the correct HTML format. I'm using sublime text's Regex but can use another platform if you have any tips.

Example source

[url=https://example.com/example]URL Text[/url]

Result i'm looking for

<a href="https://example.com/example">URL Text</a>

I have found this article but the example does not work for me. Due to my inexperience with regular expressions I've not been able to find a solution. Any tips are appreciated.

Upvotes: -2

Views: 98

Answers (1)

Nils R.
Nils R.

Reputation: 1

I've managed to replace the BBcode URL's with the following Python regex in Sublime:

Search:

\[(url=)(.*?)\](.*?)\[/url]

Replace:

<a href="\2">\3</a>

Upvotes: 0

Related Questions