Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Special Characters to Use in PHP Expression Test Patterns

Part of the PHP & MySQL For Dummies Cheat Sheet

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.

Character Meaning Example Match Not a Match
^ Beginning of line ^c cat my cat
$ End of line c$ tic stick
. Any single character .. me, go a
? Preceding item is optional mea?n mean, men moan
( ) Groups literal characters m(ea)n mean men,mn
[ ] Any character in set abc[1-3] abc1,abc2 abc4
[! ] Any character not in set m[!ea]n min, mon men, man
+ One or more door[1-3]+ door111, door131 door, door55
* Zero or more door[1-3]* door, door311 door4, door445
{ , } Range of repetitions a{2,5} aa,aaaaa a, xx3
\ Escapes character m\*n m*n men, mean
( | | ) Alternate strings (Tom|Tommy) Tom, Tommy Thomas, To
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
PHP & MySQL For Dummies Cheat Sheet

Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.