Have an account? Sign in
"*" indicates required fields
You agree that CreativePro Network may send you emails, including the newsletter selections above. You can unsubscribe at any time.
By signing in, you agree to our Terms of Use and acknowledge our Privacy Notice.
New user? Create an account
By signing in, you agree to our Terms of Use and acknowledge our Privacy Notice.
Hi everyone
I’m fairly new to GREP, but I started experimenting with it on the magazine that I produce and sure enough I ran into ‘The URL problem’ that everyone inevitably does! I initially came up with a fairly long code that targeted URLs that did not have ‘https://’ or ‘www.’ at the start because that was the magazine’s house style:
(\w+|\w+-|\w+/)*(\w+\.[\u]+(\.[\u]+)*)(/\w+(/w+|-\w+)*)*
But then I looked at the problem again and tried to simplify each element until I got the following:
([^]+)\.([^]+)
This (as far as I can see with the testing I have done so far) finds any url irrespective of what’s in it. I tested it on Casey’s sample text in his post and it makes the same matches (unless I missed something). I’d love any feedback or suggestions of how to improve it. I also posted this on my own blog (https://www.pixooma.co.uk/blog/2013/08/31/url-grep-simplified/) as I’d like to come back to this topic regularly.
Mark
This site uses cookies, but not the kind you eat. We use cookies to remember log in details, provide secure log in, improve site functionality, and deliver personalized content. By continuing to browse the site, you accept cookies.