문제

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