Skip to content

Instantly share code, notes, and snippets.

@jerry-sl
Last active September 9, 2017 09:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerry-sl/61e23db5e4749962bf7e67cb4a2d3b1c to your computer and use it in GitHub Desktop.
Save jerry-sl/61e23db5e4749962bf7e67cb4a2d3b1c to your computer and use it in GitHub Desktop.
Regular Expression
<h1>Ruls</h1>
• The ? matches zero or one of the preceding group.
• The * matches zero or more of the preceding group.
• The + matches one or more of the preceding group.
• The {n} matches exactly n of the preceding group.
• The {n,} matches n or more of the preceding group.
• The {,m} matches 0 to m of the preceding group.
• The {n,m} matches at least n and at most m of the preceding group.
• {n,m}? or *? or +? performs a nongreedy match of the preceding group.
• ^spam means the string must begin with spam.
• spam$ means the string must end with spam.
• The . matches any character, except newline characters.
• \d, \w, and \s match a digit, word, or space character, respectively.
• \D, \W, and \S match anything except a digit, word, or space character, respectively.
• [abc] matches any character between the brackets (such as a, b, or c).
• [^abc] matches any character that isn’t between the brackets.
• dot-star .* means anything except newline.
<h1>Samples</h1>
<a[^>]+href=["\'](.*?)["\'] Extract HTML href link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment