Tuesday, 10 September 2013

Regex to match 10 to 100 characters including an unlimited number of white spaces?

Regex to match 10 to 100 characters including an unlimited number of white
spaces?

I'm trying to match 10 to 100 of any character including new lines, while
allowing an unlimited number of white space characters within.
This Regex matches my pattern except for the unlimited spaces.
$regex = '/(.|\n|\r\n){10,100}/';
I've tried this to match unlimited white space with this pattern, but it
does not work:
$regex = '/(.|\s+|\n|\r\n){10,100}/';
The above regex doesn't make much sense by itself, so realize it's the
middle part of a bigger regex to find addresses ( roughly ). You can see
the above part in the regex below before the part looking for states.
$regex = "/\b(\d{2,5}|po|p\.o\.|post
office)(.|\n|\r\n){10,100}(AK|Alaska|AL|Alabama|AR|Arkansas|AZ|Arizona|CA|California|CO|Colorado|CT|Connecticut|DC|Washington\sDC|Washington\D\.C\.|DE|Delaware|FL|Florida|GA|Georgia|GU|Guam|HI|Hawaii|IA|Iowa|ID|Idaho|IL|Illinois|IN|Indiana|KS|Kansas|KY|Kentucky|LA|Louisiana|MA|Massachusetts|MD|Maryland|ME|Maine|MI|Michigan|MN|Minnesota|MO|Missouri|MS|Mississippi|MT|Montana|NC|North\sCarolina|ND|North\sDakota|NE|New\sEngland|NH|New\sHampshire|NJ|New\sJersey|NM|New\sMexico|NV|Nevada|NY|New\sYork|OH|Ohio|OK|Oklahoma|OR|Oregon|PA|Pennsylvania|RI|Rhode\sIsland|SC|South\sCarolina|SD|South\sDakota|TN|Tennessee|TX|Texas|UT|Utah|VA|Virginia|VI|Virgin\sIslands|VT|Vermont|WA|Washington|WI|Wisconsin|WV|West\sVirginia|WY|Wyoming)(\s|\n|\r\n|\&nbsp\;){1,3}\d{5}/i"

No comments:

Post a Comment