简体   繁体   English

PHP Regex到Java Regex

[英]PHP Regex to Java Regex

Could anybody convert some PHP regex to Java regex for me? 任何人都可以将一些PHP正则表达式转换为Java正则表达式吗? I'm new to java regex; 我是java正则表达式的新手; don't know how I would go around doing it. 我不知道怎么回事。

%\A(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])\S{4,}\z%

Also, does anybody know how to check if desired email is a valid email address layout? 此外,是否有人知道如何检查所需的电子邮件是否是有效的电子邮件地址布局?

\\在java中的字符串中你需要像\\\\一样转义它

 %\\A(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])\\S{4,}\\z%

Just need to remove the delimeter and double quote it. 只需要删除分隔符并双引号。
Put the \\w equivalent in the regex. 把\\ w等价物放在正则表达式中。
Note that if your input comes from an edit box that's single line, 请注意,如果您的输入来自单行的编辑框,
you can replace the \\A and \\z anchors with ^$ but, I use \\A and \\z 你可以用^ $替换\\ A和\\ z锚点,但我使用\\ A和\\ z
when I have to dither newlines. 当我不得不抖动换行符时。

 #   "\\A(?=[-\\w]*[A-Z])(?=[-\\w]*[a-z])(?=[-\\w]*[0-9])\\S{4,}\\z"

 \A 
 (?= [-\w]* [A-Z] )
 (?= [-\w]* [a-z] )
 (?= [-\w]* [0-9] )
 \S{4,} 
 \z

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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