Regex - Exclude match if it precedes a specific character
I am trying to parse a string and return stuff in between #
, but only if #
not preceded \
.
For example, I messed up with the following test line at regexr.com:
This is a #date # test.
Using #.*#
I can get the test I want. However, give this line:
This is a # # date test.
I don't want it to return as the backslash is before #
. So far I have come up with:
[^\\](#.*.#)
However, when the backslash is missing from the test string, it ends capturing the character before the # character. Is there a way to grab only the "# date #" part from the test string, but only if it is not preceded by a black spoon?
source to share