I have an input string like this
val input = """["abc:def&ghi:jkl"]"""
I want to extract abc and ghi So I wrote this regex which works
val regex = """(?<=["&])(\w+)(?=[:])""".r
regex.findAllIn(input).foreach(println)
So basically I have a look ahead for : and a look behind for either " or &.
So far so good. But now I have an input like this
val input = """["abc:de_&_f:xyz&ghi:jkl"]"""
it matches
abc
_f
ghi
I want to change the logic of my regex to say.
Match a \w+ when look ahead is true for : and look behind is true for & and false for _&_
So I want to use the positive and negative look behind at the same time. How do I do that?