PHP Regex到Java Regex

有人可以将一些PHP正则表达式转换为Java正则表达式吗? 我是java正则表达式的新手; 我不知道怎么回事。</ p>

 %\ A(?= [-_ a-zA-Z0-9] *?[AZ])(?  = [-_一个-ZA-Z0-9] *?[AZ])(?= [-_一个-ZA-Z0-9] *?[0-9])\ S {4,} \ž%
< / code> </ pre>

此外,是否有人知道如何检查所需的电子邮件是否是有效的电子邮件地址布局?</ p>
</ div>

展开原文

原文

Could anybody convert some PHP regex to Java regex for me? I'm new to java regex; 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?

2个回答



只需删除分隔符并双引号即可。

在正则表达式中输出\ w等效。
\ n注意如果你的输入是来自单行的编辑框,你可以用^ $替换\ A和\ z锚点但是,我使用\ A和\ z

当我不得不抖动换行符时 。 </ p>

 #“\ A(?= [ -  \ w] * [AZ])(?= [ -  \ w] * [az])(?=  [ -  \ w] * [0-9])\ S {4,} \ z“

\ A
(?= [ - \ w] * [AZ])
(?= [ - \ w] * [az])
(?= [ - \ w] * [0-9])
\ S {4,}
\ z
</ code> </ pre> \ n </ div>

展开原文

原文

Just need to remove the delimeter and double quote it.
Put the \w equivalent in the regex.
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
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



\ </ code>在java中的字符串中,您需要像 \ </ code>一样将其转义 </ p>

 %\ A(?= [-_ a-zA-Z0-9] *?[AZ])(?= [-_ a-zA-Z0-9]  *?[AZ])(?= [-_一个-ZA-Z0-9] *?[0-9])\Š{4} \ž%
</代码> </ PRE>
</ DIV>

展开原文

原文

\ in a string in java you need to escape it like \\

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐