I have a the following regex expression which finds dates in a text file:
(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})
I want to find the character that precedes this search string. Can anyone point me in the right direction. The preceding character is a , (comma) which I want to search and replace.
You’ll want to use positive lookahead to accomplish this:
This pattern will match the comma, but only if it’s followed by something that matches the pattern you’ve provided in the question. (Note that with search/replace, it will not replace the date)