Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regex code to filter email:The password must be contain at least one capital letter and two numbers

Posted on 2016-11-08
16
Medium Priority
?
149 Views
Last Modified: 2016-11-11
Regex code to filter email:The password must be contain at least one capital letter and two numbers ??
thank you
0
Comment
Question by:john lambert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
16 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41878595
Hi,

pls try
([a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}):(?:.*?([A-Z].*\d.*\d|\d.*[A-Z].*\d|\d.*\d.*[A-Z]).*?)

Open in new window

Regards
1
 

Author Comment

by:john lambert
ID: 41878617
Not working
At least one capital letter  and 2 numeric, i tried to register with this type of pass and let me register i test ur code but dones't work
One capital letter?must be thisuppercase or lowercase  a,b,c,d  or A,B,C,D and 2 numeric
So pass must look like this to make a test:
Aa1234
a12
A12
b12@
b1234567!
abcd1234
john@123
A123#
a12#
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41878620
I test the pw after the :(colon)
Supposition
first the email : (colon) then the PW
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:john lambert
ID: 41878623
yes i tried to register with :
a12
A12
b12
and dones't work then i succesfully registered with this:

Amin123#
0
 

Author Comment

by:john lambert
ID: 41878627
yes look like this:

John@ymail.ro:Amin123#
0
 

Author Comment

by:john lambert
ID: 41878628
but i don't know if can register with amin123 for example....
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41878631
then try
([a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}):(.*?([A-Z].*\d.*\d|\d.*[A-Z].*\d|\d.*\d.*[A-Z])\S*)

Open in new window

1
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41878634
amin123 has no capital letter
0
 

Author Comment

by:john lambert
ID: 41878649
yes this works well, if ur sayng capital letters are form A- Z then yes, working fine
thank you
0
 

Author Comment

by:john lambert
ID: 41878650
so i tried to register again with Amin123 dones't work....only Amin123# ,Try to use a random email and then try Amin123 as pass to register u can see dones't work then try to use Amir123# is work and u receive the msg: Registration successfull.
Activation mail sent!

maybe need a special char too
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41878668
then try
([a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}):(.*?([A-Z].*\d.*\d|\d.*[A-Z].*\d|\d.*\d.*[A-Z]).*)

Open in new window

1
 

Author Comment

by:john lambert
ID: 41878677
thankx a lot i think this is better, have a wonderfull day
thanks
0
 

Author Comment

by:john lambert
ID: 41878701
not working,this is my test.txt content:

robert@mama.ro:password1
1e722a71058df2c92891bd788d6195c9
jphn@yahoo.com:Amir123#
jphn@yahoo.com:Amir123
john@yahoo.ro:1234
robert@ymail.ro:123#
jphn@yahoo.com:amir123#
jphn@yahoo.ro:amir123#
63aae68d15628c9a4ed427171bc68885f719308c
jphn@yahoo.com:amir123

Open in new window


Output.txt should look like this:

robert@mama.ro:password1
john@yahoo.ro:1234
robert@ymail.ro:123#
jphn@yahoo.ro:amir123#

Open in new window


but the output.txt is empty
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 2000 total points
ID: 41881136
Hi John,

I don't get what you want with the text file, but this RE is matching when you input a valid password with one uppercase A-Z and 2 numbers:

(?=.*\d)(?=.*\d)(?=.*[A-Z]).{3,}$

If you want to parse your text file to find the valid passwords, add a colon at the start:

:(?=.*\d)(?=.*\d)(?=.*[A-Z]).{3,}$
1
 

Author Closing Comment

by:john lambert
ID: 41884067
thank you..........
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question