|
|
Tutorials

Regular-expression

|
Topic |
What is [[:cntrl:]] Character Class?
|
|
Explanation |
|
The [[:cntrl:]] character class matches characters that dont give an output as such but still controls
system. Some of the control characters are form feed, backspace, tabspace character etc. All these characters have ASCII value less than 31.
PHP Example:
<?php
$org = "IIÏÏïï";
$det = ereg_replace("[[:cntrl:]]","V",$org);
echo $det;
?>
Result:
IIVII
In the above example the character class "[[:cntrl:]]" is used to replace the tab space which is
also a control character with "V".
Perl Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
$str = "\001";
if ($str =~ m/[[:cntrl:]]/)
{print "Matches!";}
else
{print "Unmatch!";}
Result:
Matches!
In the above example the control character ascii value "\001" is matched using the character class "[[:cntrl:]]",
since it displays matched.
|
| A Note |
Simple Regex Regular Expression Tutorial Online. We welcome your Valuable feedbacks or suggestions. This is a copyright content.
|
|
|
|