use regex to find based on 2 characters but only replace one
-
I’d like to find all instances of a comma that are followed by a non-whitespace character, and then replace the comma with a line break but leave the non-whitespace character alone.
It’s easy enough to find these matches using
[,](\S)But I can’t figure out how to only replace the comma portion of the match… or even what the name of the approach/technique is so that I can read up on it. Any advice?
(I worked around the problem for now by replacing comma followed by space with another symbol, then replacing all commas, then replacing the other symbol with comma + space again, but that’s a workaround I’d like to skip in the future.)
-
-
lookbehind and lookahead assertions … aren’t part of the “real” match
That’s the concept I wasn’t able to name.
Not sure why you made the comma a single thing inside the [ and ] …
Because I barely know what I’m doing and was piecing it together from possibly applicable Stack Exchange posts.
Anyway, thanks, you nailed it!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login