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
21 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
  • 9
  • 5
16 Comments
 
LVL 48

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 48

Expert Comment

by:Rgonzo1971
ID: 41878620
I test the pw after the :(colon)
Supposition
first the email : (colon) then the PW
0
 

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 48

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 48

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 48

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 37

Accepted Solution

by:
Gerwin Jansen earned 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now