Regular Expression





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Regex Topics
Introduction Introduction
Common Metacharacter Common Metacharacter's
Metacharacters Metacharacter's
Qualifiers Quantifier's
Word Boundry Word Boundry
Non-word Boundry Non-word Boundry
POSIX Character Classes POSIX-Character Classes
Feedback Feedback
Forums Ask Your Doubts
 




"cntrl" Character Class.


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.


Other Links

web hosting