How to alert a regex match. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to alert a regex match.

Guys, I have a question. How do you make a code to output a RegEx value. Like, when you have a RegEx that checks for some values, how do you make it alert the value that matched the RegEx. For example, if I have a RegEx that checks if a word has vowels, how do I make it alert the vowel it found im the word (like alerting "e" if the word is "then")

14th Feb 2020, 5:13 PM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
2 Answers
+ 2
use String.match() it'll return the found match as an array. "then".match(/e/g);
14th Feb 2020, 5:27 PM
Taste
Taste - avatar
15th Feb 2020, 8:25 AM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar