I'm trying to remove some characters from a string using search and replace and Regex.
I find the Regex learning curve a bit overwhelming...
HFT-COOL (Surf) - Codingweb
HFT-SURFER (Surf) - Codingweb
would deliver COOL and SURFER.
So the 1st four characters and all characters after the first space need to be removed (including the space itself). Any pointers? Thank you!
Just change [space] to a space.
Thanks, a step further! So the solution is Group 1. How do i refer to Group 1 in the "replace with" section?
Tested on https://regex101.com...
(Click on the Gear icon of the action you're using for more help.)
Lots of ways to skin this cat.
If you want to make sure you get the text after "HFT-", then this will work.
It also allows for multiple spaces or tabs after the key text.
UPDATED: 2020-01-04 14:10 GMT-6
Allow for searched text to be single or multiple lines
For details, see https://regex101.com/r/CG4Jvd/2/
Just made an update to handle multiple lines.
Ah, Discourse stripped the leading slash. I've edited the original post to restore it.
The way to avoid Discourse changing your text is to enclose in back quotes like:
Found a cool website to help learn Regex. Maybe someone finds it useful in the future https://regexone.com
There are several good tutorial sites for RegEx, but I do like the interactive learning feature of this one. Doing is always the best method for learning.