What is a regular expression
A regular expression is a language for specifying patterns that match a sequence of characters. Regular expressions consist of normal characters, which match the same character in the input. The following link is a great cheat sheet to help you learn all about different regular expression syntaxes:
http://www.addedbytes.com/cheat-sheets/download/regular-expressions-cheat-sheet-v1.pdf
We have also provided below some commonly used regular expressions to help you:
Regular Expression Example 1 - Find links with no www or http
To have autolinks find web links with no www or http you will need to use a regular expression.
An example of such a regular expression is the following:
Expression: .*?(\S*(\.com|\.net|\.org|\.co.uk|\.edu|\.gov)\S*)
Link: ##1##
You can modify this regular expression to fit your needs.
Regular Expression Example 2 - Find ISBN Numbers on a publication
To have autolinks find some ISBN numbers on your publication try the following regular expression:
Example ISBN: 123-1-12345-123-1
Expression: .*?(([0-9]{3})-([0-9]{1})-([0-9]{5})-([0-9]{3})-([0-9]{1})).*?
Link: http://www.site.com/catalogue.asp?isbn=##2####3####4####5####6##
You may need to modify this regular expression to fit your needs or your ISBN number style
Regular Expression Example 3 - Find product code on a publication
To have autolinks find a sample five character product code on your publication try the following regular expression:
Example Product code: ABC-123
Expression: .*([A-Z0-9]{3})(-)([A-Z0-9]{3}\b).*
Link: http://www.site.com/catalogue.asp?prodid=##1##
You may need to modify this regular expression to fit your needs or your product code number style
Regular Expression Example 4 - Finding random numbers of xxxxx
To have autolinks find a sequence of five random numbers try the following regular expression:
Example: 12345
Expression: .*([0-9]{5}\b).*
Link: http://www.site.com/catalogue.asp?code=##1##
Regular Expression Example 5 - Finding numeric codes of xxx-xxxxx
To have autolinks find a sequence of numeric codes try the following regular expression:
Example: 123-12345
Expression: .*([0-9]{3}(-)[0-9]{5}\b).*
Link: http://www.site.com/catalogue.asp?code=##1##
Regular Expression Example 6 - Finding numeric codes (with a space) of xxx xxxxx
To have autolinks find a sequence of numeric codes try the following regular expression:
Example: 123 12345
Expression: .*([0-9]{3}()[0-9]{4}\b).*
Link: http://www.site.com/catalogue.asp?code=##1##
Regular Expression Example 7 - Finding email addresses
To have autolinks find a sequence of numeric codes try the following regular expression:
Example: test@test.com
Expression: .*?([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}).*?
Link: mailto:##1##
Regular Expression Example 8 - Finding fixed number codes 12345
To have autolinks find a sequence of numeric codes try the following regular expression:
Example: 12345
Expression: .*(\<12345 \>).*
Link: http://www.site.com/catalogue.asp?code=##1##
Regular Expression Example 9 - Finding specific words
To have autolinks find a sequence of numeric codes try the following regular expression:
Example: zmags
Expression: .*(\<zmags \>).*
Link: http://www.site.com/catalogue.asp?word=##1##
Regular Expression Example 10 - Finding numbers and letters
To have autolinks find a sequence of numbers and letters try the following regular expression:
Example: 1234AB1234
Expression: .*(\b[0-9-A-Z]{12}\b).*
Link: http://www.site.com/catalogue.asp?id=##1##
Comments
0 comments
Please sign in to leave a comment.