/    Sign up×
Community /Pin to ProfileBookmark

Preg_Replace BBCODE with HTML Link

This is the current BBCODE link pattern I’m replacing with an HTML link:

[code=php]“/[URL=(.*)](.*)[/URL]/i”[/code]

However, I would like it to match both [URL=][/URL] AND the lowercase version [url=][/url]. What edits would I need to do to make this work?

[B]P.S. The backslashes are there in order to avoid triggering THIS forum’s BBCODE. You get the idea.[/B]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@SyCoDec 12.2008 — You already have it. the /i makes it case insensitive.
Copy linkTweet thisAlerts:
@SyCoDec 12.2008 — You can use these ascii codes to echo the square brackets without triggering the BB code stuff here (remove the spaces).

[CODE]& #091;

& #093;[/CODE]
Copy linkTweet thisAlerts:
@NogDogDec 13.2008 — You can also use the [NOPARSE][NOPARSE]...[/NOPARSE][/NOPARSE] tags. ?
Copy linkTweet thisAlerts:
@SyCoDec 13.2008 — Thanks, that makes it easier to tell people to
[CODE]Please use the [noparse][code=php][/code][/noparse][/CODE]
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 13.2008 — Right, didn't know that, because I copied that REGEX from a BBCODE tutorial. Sorry. Thanks everyone?
×

Success!

Help @Joseph_Witchard spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...