I'm trying with the following Regex
:
/^[aeiou]\..*[aeiou]$/
But it's not working, I tested "abcda" and didn't match.
The metacharacter \b is an anchor like the caret and the dollar sign. It matches at a position that is called a “word boundary”. This match is zero-length. There are three different positions that qualify as word boundaries: Before the first character in the string, if the first character is a word character.
To run a “whole words only” search using a regular expression, simply place the word between two word boundaries, as we did with ‹ \bcat\b ›. The first ‹ \b › requires the ‹ c › to occur at the very start of the string, or after a nonword character.
\\. matches the literal character . . the first backslash is interpreted as an escape character by the Emacs string reader, which combined with the second backslash, inserts a literal backslash character into the string being read. the regular expression engine receives the string \.
Using character sets For example, the regular expression "[ A-Za-z] " specifies to match any single uppercase or lowercase letter. In the character set, a hyphen indicates a range of characters, for example [A-Z] will match any one capital letter.
It should be just:
/^[aeiou].*[aeiou]$/
The extra \.
you had would require the second character to be a literal dot, like in: "a.hello". But since your test case "abcda" does not include such a dot, it did not match.
Note that if you want to match upper case vowels as well, you could add the i
modifier, as follows:
/^[aeiou].*[aeiou]$/i
If your intention is to only match strings where the ending vowel is the same as the vowel at the start, then use a back-reference \1
like this:
/^([aeiou]).*\1$/i
Regex for word start and end with vowel.
^[aeiou].*[aeiou]$
Regex for word start and end with same vowel.
^[a].*[a]$|^[e].*[e]$|^[i].*[i]$|^[o].*[o]$|^[u].*[u]$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With