"cntrl" Character Class.

What is [[:cntrl:]] Character Class?


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:

$org = "IIÏÏïï";
$det = ereg_replace("[[:cntrl:]]","V",$org);
echo $det;
Result :


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:programfilesperlbinperl
print "content-type: text/htmlnn";
$str = "01";
if ($str =~ m/[[:cntrl:]]/)
{print "Matches!";}
{print "Unmatch!";}
Result :


In the above example the control character ascii value "01" is matched using the character class "[[:cntrl:]]", since it displays matched.

Ask Questions

Ask Question