0

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>
1
  • Might you be looking for this? Commented Apr 7, 2014 at 6:07

2 Answers 2

1

This worked for me:

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

You could even remove the ://

(?<=(?i)href=")(?!http)((?:<\?php(?:(?!\?>).)+\?>)?)((?:'[^']+')?)([^"]+)(?=")
Sign up to request clarification or add additional context in comments.

Comments

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

demo here :

http://regex101.com/r/kZ3tO9

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.