简体   繁体   中英

Javascript Regex matching logical or

I am wondering if JavaScript includes the logical or when pattern matching. I would like to check if the user is either using @hotmail.com or @gmail.com, with anything allowed to come before it, and nothing allowed after the @hotmail or @gmail.com. Instead of having to write two separate conditions to check each one is there away to combine it into one test. Thank you.

试试这个正则表达式:

/^(.+)@(hotmail|gmail)\.com$/

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM