I am trying to validate the following strings:
org/com[2]/net[4]/uk@name
org/com[2]/net[4]
Why doesn’t the following regular expression work:
(((.*(\[.*?\])((\/)?)))|(\@(.*)))
Please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your expression can be broken down to
(.*(\[.*?\])((\/)?)), or(\@(.*))The former part can be broken down into
.*, followed by\[.*?\](which is not the same as(\[.*\])?) , possibly followed by/Here’s another suggestion:
Test cases:
Output: