Instructions
1. The matching pattern you want to search may have parts that are not sure to exist. You can use question marks to specify possible elements.
2. This will check the previous zero or one element. This symbol can be considered as the preceding element.
Example
要求 修改正则表达式 favRegex 以匹配美式英语(favorite)和英式英语(favourite)的单词版本。 let favWord = "favorite"; let favRegex = /change/; // 修改这一行 let result = favRegex.test(favWord); 参考 let favWord = "favorite"; let favRegex = /favou?rite/; // 修改这一行 let result = favRegex.test(favWord);
The above is the detailed content of How to search for possible elements with javascript. For more information, please follow other related articles on the PHP Chinese website!