I would like to find a regex and replacement to do all the following tasks at once:
- Replace all
's
that are ending words to the same word but withs
instead (regex:'s\b
, replacement:s
) - Remove all non-word characters at the start and at the end of the string (regex:
^\W*(.*?)\W*$
, replacement:\1
) - Replace all consecutive other non-word characters with a single dash (regex:
\W+
, replacement:-
)
As seen I'm able to write all the rules one by one, but all together is much, much harder. I can't reduce the number of regexes to use...
I'd say that if it works on regex101, that's good enough. If it's not possible, I can accept that and saying so is good enough.
Examples:
Input ---> Output
----- ------
Hello, World! ---> hello-world
(%O'Shea's,*cAt!§ ---> o-sheas-cat