Reputation: 5163
I have found that \b
is used for capturing boundary characters in regex.
Like with regex \bnull\b
and input ,null,
it will capture null
and with input .null.
it will also capture null
What I want is to tell \b
that it should only capture null of ,null,
input and it should not consider null of -null-
.null.
etc
How can i do this?
Upvotes: 0
Views: 1011
Reputation: 10500
Edit: Updating my answer, due to added information from your comment above. Please try to give all necessary information to understand the problem when asking questions.
To match the nulls in null,raheel,email
, raheel,email,null
and ,null,
while not matching null
with any other adjacent character than comma, you can use:
(?:^|,)null(?:,|$)
See for yourself here.
Another update: New info again...
To also match the nulls in null,null,null
, you can use:
(?<=,|^)null(?=,|$)
See for yourself here.
Upvotes: 4