user2469520
user2469520

Reputation:

Changing Regex to Exclude http://

This Regex works great for converting URL's to lower case:

Search for...

(?<=(?i)href=")((?:<\?php(?:(?!\?>).)+\?>)?)((?:'[^']+')?)([^"]+)(?=")

Replace with...

\1\2\L\3

I think it might be a GREP; it works with TextWrangler but not Dreamweaver.

Anyway, I wondered if anyone knows how I can modify it so it ignores URL's that begin with http://. I only want to modify local links, which generally look like any of the following:

<a href="/World/Spain" title="Topics">Spain</a>
<a href="$G_URL/World/Spain" title="Spain">Spain</a>
<a href="'.$G_URL.'/World/Spain" title="Spain">Spain</a>

Upvotes: 0

Views: 59

Answers (2)

Amit Joki
Amit Joki

Reputation: 59232

This worked for me:

(?<=(?i)href=")(?!http://)((?:<\?php(?:(?!\?>).)+\?>)?)((?:'[^']+')?)([^"]+)(?=")

You could even remove the ://

(?<=(?i)href=")(?!http)((?:<\?php(?:(?!\?>).)+\?>)?)((?:'[^']+')?)([^"]+)(?=")

Upvotes: 1

aelor
aelor

Reputation: 11116

(?<=(?i)href=")(?!http)((?:<\?php(?:(?!\?>).)+\?>)?)((?:'[^']+')?)([^"]+)(?=")

demo here :

http://regex101.com/r/kZ3tO9

Upvotes: 0

Related Questions