RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

Change page:   |    Displaying page 2 of 2 pages; Items 21 to 35
Title Test Details Facebook Pages
Expression
http[s]?://(www|[a-zA-Z]{2}-[a-zA-Z]{2})\.facebook\.com/(pages/[a-zA-Z0-9\.-]+/[0-9]+|[a-zA-Z0-9\.-]+)[/]?$
Description
Validating a Facebook page can be a little bit tricky. This is because there are two valid formats. The first is facebook.com/pages/USERNAME/numbers/, the second is designed for big business which grants them a clean url such as facebook.com/coca-cola/. I see this regex being used in a user profile admin page and I think it does a good enough job for this purpose. The problem is bad urls could slip through which meet the criteria for the clean facebook page url but aren't in valid pages on the site. The main example being that an incomplete numbered url could slip through as http://www.facebook.com/pages/ would validate. Facebook also uses various subdomains such as en-gb.facebook.com to provide localised versions of the site. This regex will accept a prefix of either www or a locale code of two letters dash two letters. It doesn't validate the actual country code though. [UPDATED] Added full stop to list of valid characters for page names.
Matches
http://www.facebook.com/pages/Andy-Worthington/196377860390800 | http://en-gb.facebook.com/pages/Andy-Worthington/196377860390800 | http://www.facebook.com/pages/ | http://www.facebook.com/coca-cola/ | http://www.facebook.com/thesimpsons/
Non-Matches
http://facebook.com/pages/Andy-Worthington/196377860390800 | www.facebook.com/pages/Andy-Worthington/196377860390800 | http://www.facebook.com/people/Andy-Worthington/738143803
Author Rating: Not yet rated. Matthew Harris
Title Test Details Allow digits but exclude certain numbers
Expression
^(?!^(5|15|18|30)$)\d+$
Description
Because a regular expression only deals with a single character at a time it can be a challenge to work with numbers as they often contain multiple digits. This regex allows any number except the numbers in the list. It does this by using a negative look ahead to fail the regex if it finds an excluded number.
Matches
1 | 325 | 515 | 300
Non-Matches
5 | 15 | 18 | 30
Author Rating: Not yet rated. Matthew Harris
Title Test Details Google Analytics Account Id
Expression
^UA-\d+-\d+$
Description
This is an intentionally loose implementation. The number in the middle (account num) is constantly increasing as new accounts are made. The number on the end represents the profile number which shouldn't go over 50 but I haven't locked this down so that both elements are future proofed.
Matches
UA-686645-1 | UA-71354555-50 | UA-1-1
Non-Matches
UA-686645-1DD | UA-68DD6645-1 | GA-686645-1
Author Rating: Not yet rated. Matthew Harris
Title Test Details Optional Querystring
Expression
(?:\?=.*)?$
Description
Add this on to the end of your url rewriting regex to allow an optional querystring to be appended to whatever you are matching. Useful for example when you set up a Google PPC campaign and all of your urls break. Note: doesn't handle #fragments.
Matches
?with=querystring | | ?with=multiple&query=strings
Non-Matches
?with=querystring#fragment
Author Rating: Not yet rated. Matthew Harris
Title Test Details Match Default Document + Optional Querystring
Expression
^~/(?:default\.aspx)?(?:\?=.*)?$
Description
Designed for asp.net default document matching. It allows either a plain url (~/) or a default document url (~/default.aspx) both with an optional querystring. Cassini and IIS7 handle default document matching differently. The user could type it either way. The breadcrumb / sitemap system is funny about omitting default.aspx. Note: Doesn't handle #fragements
Matches
/default.aspx | /default.aspx?query=string | / | /?query=string
Non-Matches
/default.aspx#fragment | /default.aspx?query=string#fragment | /#fragment | /?query=string#fragment
Author Rating: Not yet rated. Matthew Harris
Title Test Details UK Postcode District (Loose Match)
Expression
[A-Za-z]{1,2}[\d]{1,2}[A-Za-z]{0,1}
Description
The postcode district is the first block of a UK postcode. For example with DN55 1PT it would match DN55. Its a loose match as it only ensures that the format is correct, it doesn't validate the letters and numbers. It doesn't let in the non-geographic codes postcodes SAN TA1 and GIR 0AA. It will pull out the first block of any of the matching examples below. Examples of the names of the different parts of a UK postcode can be found here: http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Life-cycle_of_post_codes
Matches
AA9A 9AA | A9A 9AA | A9 9AA | A99 9AA | AA9 9AA | AA99 9AA | EC1A 1BB | W1A 1HQ | M1 1AA | B33 8TH | CR2 6XH | DN55 1PT
Non-Matches
SAN TA1 | GIR 0AA
Author Rating: Not yet rated. Matthew Harris
Title Test Details UK Postcode Sector (Loose Match)
Expression
[A-Za-z]{1,2}[\d]{1,2}[A-Za-z]{0,1}\s*[\d]
Description
The postcode sector is the first block (the postcode district) of a UK postcode plus the first number of the second block. For example with DN55 1PT it would match DN55 1. Its a loose match as it only ensures that the format is correct, it doesn't validate the letters and numbers. It doesn't let in the non-geographic codes postcodes SAN TA1 and GIR 0AA. It will pull out the first block & the sector code of any of the matching examples below. Examples of the names of the different parts of a UK postcode can be found here: http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Life-cycle_of_post_codes
Matches
AA9A 9AA | A9A 9AA | A9 9AA | A99 9AA | AA9 9AA | AA99 9AA | EC1A 1BB | W1A 1HQ | M1 1AA | B33 8TH | CR2 6XH | DN55 1PT | AA9A9AA | A9A9AA | A99AA | A999AA | AA99AA | AA999AA
Non-Matches
SAN TA1 | GIR 0AA
Author Rating: Not yet rated. Matthew Harris
Title Test Details Parcelforce - UK tracking code
Expression
^([A-z]{2}\d{7})|([A-z]{4}\d{10})$
Description
UK Parcelforce delivery tracking code for internal UK posts. Comes in two formats 2 letters and 7 numbers (e.g. AA1234567) and 4 letters and 10 numbers (e.g. AAAA1234567890). Case insensitive.
Matches
AA1234567 | AAAA1234567890
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details Parcelforce - International tracking of exports
Expression
^([A-z]{2}\d{9}[Gg][Bb])|(\d{12})$
Description
UK Parcelforce delivery tracking code for international tracking of exports. Comes in two formats: 2 letters and 9 numbers and GB (e.g. AA123456789GB) and 12 numbers (e.g. 123456789012). Case insensitive.
Matches
AA123456789GB | 123456789012
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details Parcelforce - International tracking of imports
Expression
^[A-z]{2}\d{9}(?![Gg][Bb])[A-z]{2}$
Description
UK Parcelforce delivery tracking code for international tracking of imports. Uses a negative look ahead to prevent it ending in GB which would be an international export code.
Matches
AA123456789AA
Non-Matches
AA123456789GB | AA123456789gb | AA123456789Gb | AA123456789gB
Author Rating: Not yet rated. Matthew Harris
Title Test Details Parcelforce - All Tracking Codes
Expression
^(?<ParcelForceUK>(?:[A-z]{2}\d{7})|(?:[A-z]{4}\d{10}))$|^(?<ParcelForceExport>(?:[A-z]{2}\d{9}[Gg][Bb])|(?:\d{12}))$|^(?<ParcelForceImport>[A-z]{2}\d{9}(?![Gg][Bb])[A-z]{2})$
Description
A combined version of my other three Parcelforce tracking code regexes listed on this site. Uses named capture groups to capture and identify between UK tracking, international export and international import tracking codes. Case insensitive.
Matches
AA1234567 | AAAA1234567890 | AA123456789GB | 123456789012 | AA123456789AA
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details TNT UK Delivery Tracking Code
Expression
^(?:[A-z]{2})?\d{9}(?:[A-z]{2})?$
Description
TNT UK delivery company consignment number tracking code for TNT Track and Trace service. The system will use the 9 digit code (e.g. 123456789) or you can use the letters as shown on your consignment note (e.g. GE123456781WW). Case insensitive.
Matches
123456789 | GE123456781WW
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details UPS - United States format
Expression
^(?:1[Zz])(?<ShipperNumber>[A-z\d]{6})(?<ServiceCode>[A-z\d]{2})(?<PackageId>\d{8})$
Description
Uses named capture groups to extract components. More information on the components meanings can be found on the wikipedia page list in the source.
Matches
1z5475953256813457 | 1Z9999999999999999
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details UPS - UK format
Expression
^((1[Zz]\d{16})|(\d{12})|([Tt]\d{10})|(\d{9}))$
Description
As listed in on the UK UPS tracking help page (listed in the source)
Matches
1Z9999999999999999 | 999999999999 | T9999999999 | 999999999
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Title Test Details S10 (UPU Standard) Parcel Tracking Code
Expression
^(?<ServiceCode>[A-z]{2})(?<ParcelNumber>\d{8})(?<CheckDigit>\d{1})(?<IsoCountryCode>[A-z]{2})$
Description
Uses named capture groups to parse an S10 (UPU standard) code which is the tracking format used by many postal services including the United States Postal Service and most European Postal Services. Full spec in source link.
Matches
AA473124829GB
Non-Matches
non | matching | examples
Author Rating: Not yet rated. Matthew Harris
Change page:   |    Displaying page 2 of 2 pages; Items 21 to 35

Copyright © 2001-2017, RegexAdvice.com | ASP.NET Tutorials