سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top