/    Sign up×
Community /Pin to ProfileBookmark

preg_replace new line at

I have a string of test, how can I use preg to create a new line if it sees ? thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 13.2006 — To match a backslash use four backslashes in the expression.
Copy linkTweet thisAlerts:
@BrutusUnixauthorDec 14.2006 — Not working for some reason

Example of what I'm trying to do is on http://www.freebsdworld.net/ports/port.php?p=mod_backhand

The site link says: people.FreeBSD.org/~seanc/ports/mod_backhand/

But link goes to: http://mirrors.omniti.com/mod_backhand/ http://people.FreeBSD.org/~seanc/ports/mod_backhand/

it should be two different links with a <br> for each link is on a different line, code I'm using:

[CODE]preg_replace('@(.*://)(http://.)?(.*)@', '<a href="\1\2\3" target="_blank">\3</a>', $row['Site']);[/CODE]
Copy linkTweet thisAlerts:
@ShrineDesignsDec 14.2006 — Huh?!?!
Copy linkTweet thisAlerts:
@bokehDec 14.2006 — [code=php]$expression = '@(http://((?!http).)+)(http://[^/]+/)([^s]+)@';[/code]
×

Success!

Help @BrutusUnix 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.15,
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,
)...