0

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?

0

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

\ 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%

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.