mercredi 2 septembre 2015

String pattern, regular expression

I would like to learn something about using string patterns.

For an email I have that

^[a-zA-Z0-9_]+@[a-zA-Z0-9]+\\.[a-z]+

It should be ok, or something to make better? I dont want anything complicated, just basic "friendly readable". Is there any way how to limit email domain for 2-3 chars via expression?

And for URL I've started with something like that

^(http|https)://[a-zA-Z0-9]+\\.[a-z]+(/[a-zA-Z0-9-_]+)+\\.[a-z_-]+

How to extend patter for URL parameters? Like:

http://ift.tt/1UmHzUS

Any ideas how to simply make pattern for ?param1=val1&param2=val2?

There can be parameters, but they aren't mandatory.

Aucun commentaire:

Enregistrer un commentaire