lundi 7 mai 2018

Regexp - find specific string in comma separated string

String to find

b

Tested strings

  1. b,ffb,x
  2. b
  3. <empty-string>
  4. x,b
  5. df,b,x

Poor attempt

[\s|,|^]+(b)[\s|,|$]+

  1. [\s|,|^]+ - find white space, comma or beginning of string
  2. (b) - find the desired string
  3. [\s|,|$]+ - find white space, comma or end of string

Notes

if b defined twice I want to have a match as well

Aucun commentaire:

Enregistrer un commentaire