In a given string develop a pattern to match any occurrence of letter “b” , Where it should not follow letter “a”.
For example:
abc or ab should not match, b ba, bb, cba should match.
I tried the following regex:
**/(?!.*ab)(?=.*b)^(\w+)$/**
The foll inputs are working fine:
abba
dbcd
bacdba
bacd
adfjldb
dkfjb
abdfdsba
but where as if I give the input in a single line like:
ab ba abdkfjdk bacdk dkekfba
it is not matching the words.