Here lies all the regular expressions that I found useful
regex101: build, test, and debug regex
Find: ^(\d)/(\d)/(\d{4}),
Replace: 0$1/0$2/$3,
Converts any combination:
1/1/2024, → 01/01/2024,5/9/2024, → 05/09/2024,9/7/2024, → 09/07/2024,Find: ^(\d)/(\d{2})/(\d{4}),
Replace: 0$1/$2/$3,
Converts:
1/15/2024, → 01/15/2024,5/31/2024, → 05/31/2024,9/28/2024, → 09/28/2024,Find: ^(\d{2})/(\d)/(\d{4}),
Replace: $1/0$2/$3,
Converts:
10/5/2024, → 10/05/2024,11/3/2024, → 11/03/2024,12/7/2024, → 12/07/2024,These three regexes work for all months (1-12) and all days (1-31)! The \d wildcard matches any digit.
get anything to the right of --
/(?<=\-\-).*/
get anything to the left of --
/^.*(?=\-\-)/
get anything between [ ]
/(?<=\[).*(?=\])/
finds string between ]( & ) → used to find string between ]( & ) i.e. [link](http://this.com)
/(?<=\]\().*(?=\))/g
replace any special characters that OS's don't like
STRING.replace(/[&#\@\!, +()$~%'":*?<>{}]/g, '_')
Only alphabet characters are allowed for this field. NO spaces
/^[aA-zZ]+$/,
phone number validation
/^([+]?\d{1,2}[-\s]?|)\d{3}[-\s]?\d{3}[-\s]?\d{4}$/
Standard Password
/^(?=.*[A-Z])(?=.*[!@#$&*])(?=.*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8,40}$/
^ Start anchor
(?=.*[A-Z].*[A-Z]) Ensure string has two uppercase letters.
(?=.*[!@#$&*]) Ensure string has one special case letter.
(?=.*[0-9].*[0-9]) Ensure string has two digits.
(?=.*[a-z].*[a-z].*[a-z]) Ensure string has three lowercase letters.
.{8} Ensure string is of length 8.
$ End anchor.
Find a every line that starts with (with wildcard). Useful with iTunes XML Playlist to m3u Converter
# don't forget to excape any slashes \/
^\/Volumes\/edata\/iMusicLibrary\/.*$
# select any line that starts with "#EXTINF:" could have any number after colon, and ends with comma.
# examples that are removed: "#EXTINF:177,", "#EXTINF:246,", "#EXTINF:192,"
^#EXTINF:.*?,
get file name extension
let file = url.match(/?<=\.)[^.\\/:*?"<>|\r\n]+$/)
console.log(file[0])
remove file extension from path
filePath.replace(/\.[^/.]+$/, '')
Find and Replace string between and but starts with [[http const regex = \[\[(http.*?)\]\]
// replace string
[link]($1)
// `$` means the output variable
find replace string between [and ](
const regex = \[(.*)\]\((.*)\)
replace string --> $1
An <input> element with type="email" that must be in the following order: characters@characters.domain (characters followed by an @ sign, followed by more characters, and then a "."
After the "." sign, add at least 2 letters from a to z:
<form action="/action_page.php">
<label for="email">Email:</label>
<input type="email" id="email" name="email"
pattern="[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$">
<input type="submit">
</form>
find
2023/03/16 Retirement Account
Assets:Checking:Chase -10 USD
Assets:Investments:Unknown
and replaces it with
2023/03/16 Retirement Account
Assets:Checking:Chase -10 USD
Assets:Investments:Retirement Account
Regex
// regex find
^(\d{4}/\d{2}/\d{2} Retirement Account.*\n.*Assets:Checking:Chase.*\n) Assets:Investments:Unknown
// replace with
$1 Assets:Investments:Retirement Account
Select a result to preview