I need some way to check if a word ends with certain letters. Basically, the user enters a string, which is split into words using:
var res = spanish.split(" ");
After this I need a way to check if any words in the string contain the letters 'est'. Right now I'm accomplishing that using
if (spanish.indexOf("est") !=-1) {
}
After this, I need a way to check if the word containing 'est' ends with 'oy'. Any ideas?
I would use regex.
> /^.*est.*oy$/.test('fooestoy')
true
> /^.*est.*oy$/.test('fooesto')
false
>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.