简体   繁体   中英

Use alpha numeric with with hyphen and underscore

I've created the following regex which is not working to support the following. 1.accept alpha numreic with hyphen '-' and underscore only 2.can start only with alpha 3.can end with space

I try with the following and its not working. any idea?

"^[a-zA-Z0-9][\da-z-.]*[a-zA-Z0-9]*$"

根据您的条件,以下正则表达式是您想要的:

^[a-zA-Z][\\w-]*\\s*$

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