|
|
blank Character Class in Regular expression
|
Tutorials

Regular-expression

|
Topic |
What is [[:blank:]] Character Class in regex?
|
|
Explanation |
|
The [[:blank:]] represents horizontal space, tab-space characters in regular expression.
PHP Example:
<?php
$str = 'A12 34ax$ xxxx';
$ret = ereg_replace("[[:upper:]]|[[:blank:]]","B",$str);
echo $ret;
?>
Result:
B12B34ax$Bxxxx
In the above example for regex the character class "[[:blank:]]" is used along with "[[:upper:]]" to match a string that is in
uppercase and having one or more tab or blank-space.
Perl Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
$str = "A A AA";
if ( $str =~ /[[:blank:]]{1,2}/ )
{print "Matches!";}
else
{print "Unmatch!";}
Result:
Matches!
In the above example for regex the string "A A AA" has a two blank-spaces, so does tha pattern "[[:blank:]] {1,2}" which
specifies number of blank-spaces minimum "1" space and utmost "2" blank-spaces.
|
| A Note |
Simple Regex Regular Expression Tutorial Online. We welcome your Valuable feedbacks or suggestions. This is a copyright content.
|
|
|
|