Tested regular expressions you can open in the tester, read the explanation of and adapt. Each pattern comes with sample text and unit tests. Save your own pattern with Save & share and tick “publish” to add it here.
7 patterns
^[ \t]+|[ \t]+$
Selects spaces and tabs at the start or end of every line – replace with nothing to trim.
[\p{L}\p{M}]+(?:['’-][\p{L}\p{M}]+)*
Unicode letters and marks with the u flag – also matches Thai, accented and other scripts.
(?<![\w@#])([#@])([\p{L}\p{N}_]+)
#hashtags and @mentions, Unicode letters included (u flag). Group 1 is the symbol, group 2 the name.
[A-Z][^.!?]*[.!?]
A sentence starts with an uppercase letter and ends with . ! or ?.
^\s*$\n?
Matches empty lines and lines with only whitespace – replace with nothing to remove them.
\b(\w+)\s+\1\b
Finds a word repeated twice in a row ("the the"), ignoring case. Group 1 is the word.
{2,}
Finds two or more spaces in a row; replace with a single space.