Java Regular Expressions Pattern

Java examples for Regular Expressions:Pattern

Description

Click the following links for the tutorial for Regular Expressions and Pattern.

  1. Classes Pattern and Matcher.
  2. Extracting matched expressions, Email Address Finder
  3. Backslashes in regular expressions
  4. Java regular expression syntax quick reference
  5. Regular expression Pattern class options
  6. Test Harness for Regex
  7. Catch PatternSyntaxException and get information from it
  8. Using a Non-Capturing Group in a Regular Expression


  9. Escaping Special Characters in a Pattern
  10. Adding Comments to a Regular Expression
  11. Using the Captured Text of a Group within a Pattern
  12. Setting Case Sensitivity in a Regular Expression
  13. Greedy and Nongreedy Matching in a Regular Expression
  14. Compiling a Pattern with Multiple Flags
  15. Capturing Text in a Group in a Regular Expression
  16. Use split method to split a string based on delimiters that match a regular expression


  17. Let a user enter the area code for a phone number with or without parentheses.
  18. | symbol defines an 'or' operation
  19. Reference group in regular expression
  20. Create regular expression for U.S. phone numbers with an optional area code
  21. Using parentheses to group characters
  22. Using escapes In regular expressions with a backslash
  23. ? quantifier create an optional element that may or may not be present in the string
  24. Duplicating elements rather than using a quantifier \d\d is \d{2}
  25. Matching multiple characters any times with Quantifiers
  26. What does \d\W[a-z] mean in regular expression
  27. Using negation in Regular expressions
  28. Use ranges to build a class that accepts only characters that appear in real words
  29. Create more than one range in a class
  30. Create ranges for pattern with [a-z]
  31. Create classes for the first and last characters so they too can be upper- or lowercase:
  32. Let the pattern include uppercase letters as well as lowercase letters
  33. Using custom character classes
  34. \w matches word character (a-z, A-Z, 0-9, or an underscore) and \W matches non word character
  35. Limit white space characters to actual spaces, just use a space in the regex.
  36. \S matches any character that isn't a white space character.
  37. \s class matches white space characters including spaces, tabs, newlines, returns, and backspaces.
  38. \D class matches any character that is not a digit.
  39. \d class represents a digit and use it to validate a U. S. Social Security number, XXX-XX-XXXX
  40. Using predefined character classes
  41. Use regex patterns to match a string literal exactly
  42. Removing accents and diacritics from given text .
  43. Compile a pattern that can will match a string if the string contains any of the given terms.
  44. Compile a pattern that can will match a string if the string starts with any of the given terms.
  45. Compile a pattern that can will match a string if the string equals any of the given terms.
  46. Regular Expression with Multiple Excludes