Advertisement
killerbng

preg_replace stuff

Jan 6th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. The following should be escaped if you are trying to match that character
  2.  
  3. \ ^ . $ | ( ) [ ]
  4. * + ? { } ,
  5.  
  6. Special Character Definitions
  7. \ Quote the next metacharacter
  8. ^ Match the beginning of the line
  9. . Match any character (except newline)
  10. $ Match the end of the line (or before newline at the end)
  11. | Alternation
  12. () Grouping
  13. [] Character class
  14. * Match 0 or more times
  15. + Match 1 or more times
  16. ? Match 1 or 0 times
  17. {n} Match exactly n times
  18. {n,} Match at least n times
  19. {n,m} Match at least n but not more than m times
  20.  
  21. More Special Character Stuff
  22. \t tab (HT, TAB)
  23. \n newline (LF, NL)
  24. \r return (CR)
  25. \f form feed (FF)
  26. \a alarm (bell) (BEL)
  27. \e escape (think troff) (ESC)
  28. \033 octal char (think of a PDP-11)
  29. \x1B hex char
  30. \c[ control char
  31. \l lowercase next char (think vi)
  32. \u uppercase next char (think vi)
  33. \L lowercase till \E (think vi)
  34. \U uppercase till \E (think vi)
  35. \E end case modification (think vi)
  36. \Q quote (disable) pattern metacharacters till \E
  37. Even More Special Characters
  38. \w Match a "word" character (alphanumeric plus "_")
  39. \W Match a non-word character
  40. \s Match a whitespace character
  41. \S Match a non-whitespace character
  42. \d Match a digit character
  43. \D Match a non-digit character
  44. \b Match a word boundary
  45. \B Match a non-(word boundary)
  46. \A Match only at beginning of string
  47. \Z Match only at end of string, or before newline at the end
  48. \z Match only at end of string
  49. \G Match only where previous m//g left off (works only with /g)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement