|
|
Tabspace "\t" metacharacter in Regular Expression.
|
Tutorials

Regular-expression

|
Topic |
How is "\t" metacharacter is used in regular expression?
|
|
Explanation |
|
The "\t" metacharacter is used to match any tabspace in regex.
PHP Example:
<?php
$str = "hiox india";
if (preg_match("/\t/", $str, $matches))
echo "Pattern matches!";
else
echo "Pattern not matched!";
?>
Result:
Pattern matches!
In the above example for regex the string "$str" has a tab space, so it matches.
Perl Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
$str = "hi how are you";
if ($str =~ m/\t/)
{print "It's matched!";}
else
{print "It's not matched!";}
Result:
It's not matched!
In the above tabspace metacharacter example for regex the pattern "/\t/" is unmatched as the string does not
have any tab spaces.
|
| A Note |
Simple Regex Regular Expression Tutorial Online. We welcome your Valuable feedbacks or suggestions. This is a copyright content.
|
|
|
|