php-regexHow to use PHP regex to match tab?
PHP regex can be used to match tab by using the \t
character.
Example code
$string = "This\tis\ta\ttab";
$pattern = "/\t/";
if (preg_match($pattern, $string)) {
echo "Match found!";
}
Output example
Match found!
Code explanation
$string
: This is the string that will be searched for the tab character.$pattern
: This is the regular expression pattern that will be used to search for the tab character.preg_match()
: This is the PHP function used to search for a pattern in a string. It takes two parameters, the first being the pattern and the second being the string.
Helpful links
More of Php Regex
- How to use PHP regex to match whitespace?
- How to use PHP regex to match UTF8?
- How to use negative lookahead in PHP regex?
- How to get last matched occurrence in PHP regex?
- How to use PHP regex to match a nbsp HTML whitespace?
- How to match a double quote in PHP regex?
- How to use PHP regex to match an exact string?
- How to use PHP regex with the "x" modifier?
- How to use PHP regex to match an XML tag?
- How to use PHP regex to match UUID?
See more codes...