find a vowel at the begining and end with regular expression

Solutions on MaxInterview for find a vowel at the begining and end with regular expression by the best coders in the world

showing results for - "find a vowel at the begining and end with regular expression"
Glen
10 Jan 2021
1//  ^ => first item matches:
2// () => stores matching value captured within
3// [aeiou] => matches any of the characters in the brackets
4// . => matches any character:
5// + => for 1 or more occurrances (this ensures str length > 3)
6// \1 => matches to previously stored match. 
7    // \2 looks for matched item stored 2 instances ago 
8    // \3 looks for matched item stored 3 ago, etc
9
10//  $ ensures that matched item is at end of the sequence
11
12let re = /^([aeiou]).*\1$/i;
13
14return re;
15
16}