Reputation: 1173
I have been solving quizes from regex101.com. One of the problems begins like this
For every occurence of the char #, backreference the previous character.
Example: for the texta#bc# -#
, set backreferences with a, c and -.
You are not allowed to consume the hash character.
My solution to this problem is (\S)[?=#]
and I think it's correct. Works well with a#bc# -#
and abcd#
.
But the site does not accept my answer. It tells me that I am consuming the hash character. I don't know what's wrong. I am not consuming hash character and this works perfectly in my java program.
Upvotes: 1
Views: 194
Reputation: 336468
Syntax error:
(\S)(?=#)
(Don't use square brackets for lookaround assertions - [?=#]
means "one of the letters ?
, =
or #
)
Upvotes: 3