Start and End of Line You can easily match strings that start or end with certain characters. The ^ character matches the start of the string. ^hello matches hello there, hello sam, hellostop. To match the end of the string, use the $ character ere$ matches Where, and There. Character Classes [aeiou] Matches Hey, and Hi, but not Zzz. Atleast One character from the set [^aeiou] Matches Zzz, but not Hey or Hi. No character from the set ^[aeiou] String should start with an Vowel [0-9] Numbers between 0 to 9 [0-9] [0-9] Any two digit Numbers [a-zA-Z0-9_] or \w Matches character found in word ([^a-zA-Z0-9_]) or \W Anything other than a word character \s For any whitespace character \S For any non whitespace character Some examples: Zip code: ^[0-9]{5} Ex: 97213, 01267 Zip Code ^[0-9]{5}-[0-9]{4} or ^\d{5}-\d{4}$ Ex:97213-4834 ^d{1,3}$ matches 1,15,987 ^d{1, }$ One or More digits ^[+-]{0,1} \d{0,}$ matches 123, +123, -123 (?i:[aeiou]) matches hello, and HELLO, but not Zzzz. Date: ^\d{1,2}/|-\d{1,2}/|-d{4} matches 12/04/2004 or 12-04-2004
|
| Author: precee 07 Jun 2004 | Member Level: Bronze Points : 0 |
This information very usefull for programming,Give more examples please.
|
| Author: Rakesh Chander Sharma 15 Jun 2004 | Member Level: Silver Points : 0 |
Very Useful Information . Keep It up.
Rakesh
|
| Author: Resmi R 18 Jun 2004 | Member Level: Bronze Points : 0 |
It was very good.Thanx a lot..I was in need of it.
|
| Author: samuel charles finny 10 Aug 2004 | Member Level: Bronze Points : 0 |
if i want to check out whether a number is valid or not what expression v must give. for ex. we should not enter +-9,.+9,/9., and a lot like this . we must calculate in all the ways possible by permutations and combinations. also it must allow expressions like +0.9,-9.0,.... so could anyone clarify me thanks ...
|