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
 




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.


Other Links

web hosting