- Find all references to filenames ending in
.js:[^ ]+\.js - Find all blank lines:
^\r?\n\r? - Wildcard (any character and newlines):
(.|\n)+?- Eg find all
<td>s, regardless of content:<td>(.|\n)+?</td>- Include attribute(s):
<td(.|\n)+?>(.|\n)+?</td>
- Include attribute(s):
- Eg find all
- Convert
getComputedStyle(foot1).lefttofoot1.getBoundingClientRect().x: findgetComputedStyle\((.+?)\).leftand replace it with$1.getBoundingClientRect().x - Remove all
<a>tags, leaving just the anchor tag text: find<a[^>]*>(.*?)</a>and replace with$1- Only links that start with the string
/foo:<a href="/foo[^>]*>(.*?)</a>
- Only links that start with the string
- Find all URLs:
\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]- All URLs ending in
.jpg:\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|](\.jpg) - All URLs within
hrefattributes:(href=["'])(\b[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]). URL available in$2
- All URLs ending in
- Return lines where whole-word strings
fooorbar bazoccur in the line:^.*\b(foo|bar baz)\b.*\n?RegExr →- Or where
fooorbar bazstrings occur anywhere in the line:^.*(foo|bar baz).*\n?RegExr →
- Or where
- Match every line in a simple CSV file where the line contains the string
fooin the second column, but not if the stringfooalso appears in another column (requires multiline and global flags):^(?:(?!foo)[^,]*,){1}foo(?:(?:,(?!foo)[^,]*))*$RegExr → - Match URL where the domain is not
jazzkeys.fyi:^(?!https?:\/\/(.*\.)?jazzkeys\.fyi)[^ ]+$ - Match
.ac,.eduand.govdomains only:(\\.ac\\.[a-zA-Z]{2}?$)|(\\.edu(\\.[a-zA-Z]{2})?$)|(\\.?gov(\\.[a-zA-Z]{1,4})?$)- Will match domains like
unimelb.edu.au,blogs.gov.scotandgla.ac.uk
- Will match domains like
Last active
April 8, 2024 10:58
-
-
Save donbrae/debf185733a0281bcc0a9e65330b3b57 to your computer and use it in GitHub Desktop.
Some regular expressions for finding patterns in text.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment