Si8 Si8 - 5 months ago 9
jQuery Question

How to modify regex to match in a sentence

How can I modify the

RegExp
to handle multiple words match in a sentence.

For example, right now it can match one word. If I enter
Ac
it will find it. But as in the fiddle example, if I type
Ag
, instead of showing the
AdidasAgain
box, it doesn't show anything.

I tried with
.
instead of
^
, now if I use
a
as a selection, it only shows
AdidasAgain
and
Azan
, but it should still show everything because they all have
a

Answer

Change the ^ to .*. ^ means that it is the start of the line, where .* means any number of any characters.