javascript - MongoDB regex does not match string between 2 pipes -


so want regex match type of elements, regex created in javascript.

i assume in mongo need \\ escape instead of one

element: toto|titi|tata|tete

  • if value tete or titi or tata or tete return false

  • if value to or ze or we return true

  • toto|titi value not matter because have regex removing specials characters value (it become tototiti)

atm used "(^|\|)" + value + "(\||$)" opposite - when value tete or titi or tata or tete return true

  • when value to or ze or we return false

i tried

  • "(^|\|)(?!" + value + ")(\||$)" didn't work

  • "(^|\|)(?!" + value + ").*(\||$)" didn't work

i have no more idea, have 1 ?


Comments