Skip to content

pr-coder-kaya/java_regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

java_regex

  • A Regular Expression is a sequence of characters that constructs a search pattern

  • You can use Regex to search for data in a given text.

  • Regex is a specific condition for a String and can find it, check if it matches, or manipulate the string to its liking.

  • Regex consists of 2 classes, Matcher and Pattern.

  • Example of a regex pattern: [a-z0-9]{3,15} -> This example looks for a pattern that contains lowercase letters or digits and length to be between 3 and 15 inclusive

  • REGEX Single Character

    • [abc] -> a, b or c
    • [^abc] -> any character except a, b or c
    • [a-zA-Z] -> lowercase or uppercase letter
    • [a-d[m-p]] -> a to d or m to p
    • [a-z[^bc]] -> a to z but not b or c
  • REGEX Quantifiers

    • X? -> X occurs once or not
    • X+ -> X occurs more than one time
    • X* -> X occurs zero or more times
    • X{n} -> X occurs n times only
    • X{n,} -> X occurs n or more times
    • X{n, m} -> X occurs at least n times but less than m times
  • REGEX Meta Characters

    • . -> represents any character
    • \d -> represents any digit character
    • \D -> represents any non-digit character
    • \s -> represents any white space character
    • \S -> represents any non-white space character
    • \w -> represents any word character a-zA-Z0-9_
    • \W -> represents any non-word character

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages