/    Sign up×
Community /Pin to ProfileBookmark

regular expressions

Ok, i am trying to change links using a regular expression. I can change all but relative links. What i am looking to do is have it ignore any link that starts with [url]http://.[/url]

[CODE]
“‘(@imports|url(|href|src)=(“|’|)(.*?)(“|’|)s'”
————————————^^
[/CODE]

Where the arrow marks is where i think it should be. I was trying something like (^[url]http://[/url]) and [^([url]http://[/url])] but neither work. Does anyone know how i can do it?

PS. I only want it to work on relative links.

Thanks.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMar 21.2005 — try("|\')</URL>?(<ESC>.</ESC>*/?.+)(1)?
Copy linkTweet thisAlerts:
@ScleppelauthorMar 22.2005 — I couldn't get your idea to work again, probably because i don't really understand regular expressions, but i have solved it! ?

I searched on google and found [URL=http://www.tote-taste.de/X-Project/regex/lookaheads.html]this page[/URL] and more importantly, this code
[CODE]"%href="(?!https?://|ftp://|mailto:|news:|javascript:|#)([^"]+)%i"[/CODE] with slight modification i got this
[CODE]"'(@imports|url(|href|src)=("|'|)(?!http://)([^"']+)("|'|)s'"[/CODE]

Thank you for your help!
Copy linkTweet thisAlerts:
@bokehMar 22.2005 — You don't need a reg ex for that. You could do a string search.

$link = 'your link here'

if (strstr($link, http://)){

print ('This link is absolute');

}else{

print ('This link is relative');

}
×

Success!

Help @Scleppel 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.18,
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,
)...