php regular expressions include "/pattern/", "^", "$", ".", "[]", "[^]", "[a-z]", "[A-Z] ","[0-9]","\d","\D","\w","\W","\s","\S","\b","*"," ", "?", "{n}", "{n,}", "{n,m}", "\bword\b", "(pattern)", "x|y", and "/i" .
The operating system of this tutorial: windows10 system, php8.1.3 version, DELL G3 computer.
php Regular expressions are a powerful tool for matching and manipulating strings. It can search, replace and extract content from strings based on specified patterns. The following are some commonly used PHP regular expressions:
1. "/pattern/": Regular expressions are usually wrapped between two slashes to define matching patterns.
2. "^": matches the starting position of the string.
3. "$": Matches the end position of the string.
4. ".": Match any character, except newline character.
5. "[]": Match any character within the brackets.
6. "[^]": Matches any character not within brackets.
7. "[a-z]": Match any lowercase letter.
8. "[A-Z]": Match any uppercase letter.
9, "[0-9]": Match any number.
10. "\d": matches any number, equivalent to "[0-9]".
11. "\D": matches any non-numeric character, equivalent to "[^0-9]".
12. "\w": matches any letter, number or underscore, equivalent to "[a-zA-Z0-9_]".
13. "\W": matches any non-letter, number or underscore, equivalent to "[^a-zA-Z0-9_]".
14. "\s": Matches any whitespace character, including spaces, tabs, newlines, etc.
15. "\S": Matches any non-whitespace character.
16. "\b": Match the boundary of the word.
17. "*": Match the previous character zero or more times.
18. " ": Match the previous character one or more times.
19. "?": Match the previous character zero or one time.
20. "{n}": Match the previous character appearing exactly n times.
21. "{n,}": Match the previous character appearing at least n times.
22. "{n,m}": Match the previous character appearing n to m times.
23. "\bword\b": Match the entire word.
24. "(pattern)": Enclose the pattern in parentheses to perform group matching.
25. "x|y": Match x or y.
26. "/i": not case sensitive.
These are a small part of PHP regular expressions. PHP also provides more regular expression functions and options that can be used according to specific needs. When using PHP regular expressions, it is recommended to refer to the relevant PHP documentation and tutorials for more detailed information and examples.
The above is the detailed content of What are the regular expressions in php. For more information, please follow other related articles on the PHP Chinese website!