Regex

"aaaa".match(/[a]/)
Result:
["a"]

"a a123a a123a b123b c".match(/a(123)a/g)
Result:
["a123", "a123"]
Note the trailing /g
  • You cannot select individual groups while using g
Last modified 3yr ago
Copy link
On this page
Matching one string
Matching multiple substrings