Special Characters to Use in PHP Expression Test Patterns

Regular PHP expressions use patterns to test whether the input users submit when using online forms are in the correct format. This table shows characters you can use in patterns.






























































































CharacterMeaningExampleMatchNot a Match
^Beginning of line^ccatmy cat
$End of linec$ticstick
.Any single character..me, goa
?Preceding item is optionalmea?nmean, menmoan
( )Groups literal charactersm(ea)nmeanmen,mn
[ ]Any character in setabc[1-3]abc1,abc2abc4
[! ]Any character not in setm[!ea]nmin, monmen, man
+One or moredoor[1-3]+door111, door131door, door55
*Zero or moredoor[1-3]*door, door311door4, door445
{ , }Range of repetitionsa{2,5}aa,aaaaaa, xx3
\Escapes characterm\*nm*nmen, mean
( | | )Alternate strings(Tom|Tommy)Tom, TommyThomas, To








dummies

Source:http://www.dummies.com/how-to/content/special-characters-to-use-in-php-expression-test-p.html

No comments:

Post a Comment