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
 




xdigit Character Class


Tutorials Regular-expression

Topic

What is the use of [[:xdigit:]]?




Explanation

This character class helps in finding hexadecimal digit character.

PHP Example:
    <?php
    $chr = 'WAB10BC99GZ'; 
    $dgt = ereg_replace("[[:xdigit:]]","#", $chr);
    echo $dgt;
    ?>
Result:
    W########GZ 

In the above example, the regular expression matches given with hexadecimal digit character. Since the string is matched, it displays "all are hex chars".

Perl Example:
    #! C:\programfiles\perl\bin\perl
    print "content-type: text/html\n\n";
    $str = "GG";
    if ($str =~ m/[[:xdigit:]]/)
      {print "Matches!";} 
    else 
      {print "Unmatch!";}
Result:
     UnMatch!

In the above example we matched a string given as "GG", using the same pattern.






A Note

Simple Regex Regular Expression Tutorial Online. We welcome your Valuable feedbacks or suggestions. This is a copyright content.


Other Links

web hosting