Handy regular expressions
This is just a memo for myself to remember all regular expression that I often use:
- Remove sh*t from movie’s subtitles (there’s a longer article on this topic here):
\(([^)]+)\)
— match everything between parentheses, including them,[A-Z ]+:
— match all uppercase letters followed by colon and a space.
- Other:
^(.+?),
— match everything from the beginning of the string until the first comma.
Surround with /
for JavaScript (and JSON?). Thus first example (\(([^)]+)\)
) becomes /\(([^)]+)\)/
.
Probably no use for anyone else except me, sorry! :>