codescracker


php

PHP Regular Expression



« Previous Tutorial Next Tutorial »


Regular expressions in PHP, are basically the sequence/pattern of characters itself. The regular expression provides the foundation for the pattern-matching functionality.

Brackets ([]) have a special meaning when used in the context of regular expressions. Let's take a look at the following table:

Expression Meaning
[a-z] This expression is used to match any character from lowercase character a through lowecase character z
[a-Z] This expression is used to match any character from lowecase character a through the uppercase character Z
[A-Z] This expression is used to match any character from uppercase character A through uppercase character Z
[0-9] This expression is used to match any decimal digit from 0 through 9

Here is another table, containing some more expression used in PHP:

Expression Meaning
[[:digit:]] This expression used to match any string containing numerical digits 0 through 9
[[:alpha:]] This expression matches any string containing alphabetic characters aA through zZ
[[:space:]] This expression matches any string containing a space
[[:alnum:]] This expression matches any string containing alphanumeric character aA through zZ and 0 through 9

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test