473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Help generating Regular Expression

I want to generate a regular expression for password check.(ASP.Net)
But javascript is what it really is.
I would like to enforce Minimum 6 alphanumeric characters with minimum 1 numeric(0-9) and 1 character(a-z) or 1 Special Character(. or _)
So far I have been able to generate something so they enter 6 alpha numberic characters, but don't know a way to check presence of 1 numeric and 1 alpha-numeric characted(or special).

"^([A-Za-z0-9\._]){6}$"

Please help.
Dec 30 '08 #1
1 1258
xNephilimx
213 Expert 100+
I think the best way to do that is by doing three checks, it may be able to do that in one single regexp pattern, but I think it's not worth the time and effort, you can do this:

Expand|Select|Wrap|Line Numbers
  1. //the following string will validate, while if it only has numbers or only letters, it won't
  2. var s = 'a.b123-ic83_87s';
  3.  
  4. if( s.match(/^[\w\._-]{6,}$/i) ) { //any word character, dashm dot or underscore, minimum 6 chars
  5.    if( s.match(/([a-z]+)/i) && s.match(/([0-9]+)/i) ) { //if it contains at least a number AND a letter
  6.       alert('ok');
  7.    }
  8. }
  9.  
  10.  
Dec 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
5
by: Karin Jensen | last post by:
Hi I am writing in PHP and trying to work with regular expressions on records in a multilanguage database. I understand regexp basics, but have bitten off more than I can chew here and really...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
9
by: =?ISO-8859-1?Q?BJ=F6rn_Lindqvist?= | last post by:
With regexps you can search for strings matching it. For example, given the regexp: "foobar\d\d\d". "foobar123" would match. I want to do the reverse, from a regexp generate all strings that could...
3
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
1
by: blackirish | last post by:
Hi all, i am trying to write a program which takes a regular expression and generate data according to that expression. I know it's possible because there are such programs to manage this task. Do...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.