0

I am using RegExp to search text like below

 RegExp(searchText, "gi").test(field)

It works fine with words.

But when i user special character like + OR * it gives me error like below

ERROR SyntaxError: Invalid regular expression: /*/: Nothing to repeat

Can anyone tell me what am i missing here?

I don't have much knowledge of RegExp

I don't want to escape these special characters. They should match/search with my field.

Duplicate question gives method to replace special characters. I want to allow special characters to match/search.

Ankur Akvaliya
  • 2,989
  • 4
  • 28
  • 53
  • 1
    _I don't want to escape these special characters._ You have to, otherwise you can't use regular expressions. – Mark Rotteveel Dec 21 '18 at 16:21
  • "I want to allow special characters to match/search." This is exactly what those duplicates do. Did you try them? – Ruzihm Dec 21 '18 at 18:09

0 Answers0