|
|
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.
|
|
|
|