I have a JSON array:
[{"name":"foo bar"},{"name":"john doe"}]
Now, I want to make a function: when I’m typing in an input field “foo”, “foo bar” has to appear. But if I type “bar”, “foo bar” has to appear also.
So how can I check if a text contains the input?
(I hope my question is clear enough)
For this simple task you don’t really need regular expressions. Here is how to find out whether a string contains a substring:
If you wanted to make the search a bit more user-friendly, you could make it case-insensitive: