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
56 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 50

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 50

Expert Comment

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

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 50

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 50

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 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count 1s in access 2016 6 54
VBA Test For Valid Number Format 6 68
Greater than or equal to 2005? 3 51
How do I remove all except the numbers?  PHP  Regex 3 43
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…
I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

809 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