Hi,
I need to validate password keyed in by the system users so that the
password will contain only letters and numbers plus at least one
capital letter. Exclude these symbols
, < ? / * ( ) & ^ % $ # ! ~ ` " '
this is my code:
ereg("[A-Za-z0-9[^\,\<\>\?\/\*\(\)\&\^\%\$\#\!\~\`\"\']]+$", $str)
am i correct? 12 17572
..oO(adzir)
>I need to validate password keyed in by the system users so that the password will contain only letters and numbers plus at least one capital letter. Exclude these symbols
, < ? / * ( ) & ^ % $ # ! ~ ` " '
this is my code:
ereg("[A-Za-z0-9[^\,\<\>\?\/\*\(\)\&\^\%\$\#\!\~\`\"\']]+$", $str)
am i correct?
Way too complicated and using the old deprecated ereg* functions.
If the PW should only contain letters and digits, then use a pattern
that matches for exactly that:
preg_match('#[A-Z\d]+#i', $str);
If there has to be a capital letter somewhere in the PW, then try a
combination like this:
preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
HTH
Micha
On May 7, 11:53 pm, Michael Fesser <neti...@gmx.dewrote
Way too complicated and using the old deprecated ereg* functions.
If the PW should only contain letters and digits, then use a pattern
that matches for exactly that:
preg_match('#[A-Z\d]+#i', $str);
If there has to be a capital letter somewhere in the PW, then try a
combination like this:
preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
HTH
Micha
Hey thanks,
I was referring an old book. I didn't noticed that there is another
function best suits to my needs. My broadband was out for a week and I
was stuck dead.
but u didn't answer my another question which was to get rid of the
symbols? anyway thanks a lot
On May 7, 5:08 pm, adzir <muad...@yahoo.comwrote:
On May 7, 11:53 pm, Michael Fesser <neti...@gmx.dewrote
Way too complicated and using the old deprecated ereg* functions.
If the PW should only contain letters and digits, then use a pattern
that matches for exactly that:
preg_match('#[A-Z\d]+#i', $str);
If there has to be a capital letter somewhere in the PW, then try a
combination like this:
preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
HTH
Micha
Hey thanks,
I was referring an old book. I didn't noticed that there is another
function best suits to my needs. My broadband was out for a week and I
was stuck dead.
but u didn't answer my another question which was to get rid of the
symbols? anyway thanks a lot
I didn't notice that there was another question. In any case, check
out strtr(), or preg_replace().
..oO(adzir)
>but u didn't answer my another question which was to get rid of the symbols? anyway thanks a lot
You don't have to. Just match on the allowed characters. If someone
enters a $, # or whatever, the matching will fail.
Micha
Michael Fesser wrote:
.oO(adzir)
>I need to validate password keyed in by the system users so that the password will contain only letters and numbers plus at least one capital letter. Exclude these symbols
, < ? / * ( ) & ^ % $ # ! ~ ` " '
this is my code:
ereg("[A-Za-z0-9[^\,\<\>\?\/\*\(\)\&\^\%\$\#\!\~\`\"\']]+$", $str)
am i correct?
Way too complicated and using the old deprecated ereg* functions.
If the PW should only contain letters and digits, then use a pattern
that matches for exactly that:
preg_match('#[A-Z\d]+#i', $str);
If there has to be a capital letter somewhere in the PW, then try a
combination like this:
preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
HTH
Micha
Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not
anchored. Use ^ and $ (and not forget /D) to make it do what you want.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
..oO(gosha bine)
>Michael Fesser wrote:
>preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Micha
On May 8, 1:31 am, Michael Fesser <neti...@gmx.dewrote:
.oO(gosha bine)
Michael Fesser wrote:
preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not
anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Micha
Where can I find a good site to explain to me all the syntax (simbols,
characters used in the preg_match function)?
php.net seems not to satisfy me.
>I need to validate password keyed in by the system users so that the
>password will contain only letters and numbers plus at least one capital letter.
Gee, many administrators would like to PROHIBIT such passwords on the
grounds that they are "too obvious".
adzir wrote:
On May 8, 1:31 am, Michael Fesser <neti...@gmx.dewrote:
>.oO(gosha bine)
>>Michael Fesser wrote: preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str); Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Micha
Where can I find a good site to explain to me all the syntax (simbols,
characters used in the preg_match function)?
php.net seems not to satisfy me.
Just google for "Regular expressions". There are thousands of them out
there, offering all levels of explanations. Many are pretty good.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
On May 11, 4:05 am, adzir <muad...@yahoo.comwrote:
On May 8, 1:31 am, Michael Fesser <neti...@gmx.dewrote:
.oO(gosha bine)
>Michael Fesser wrote:
>preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
>Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not
>anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Micha
Where can I find a good site to explain to me all the syntax (simbols,
characters used in the preg_match function)?
php.net seems not to satisfy me.
www.regular-expressions.info is a good place to start. :)
At Thu, 10 May 2007 20:05:32 -0700, adzir let his monkeys type:
On May 8, 1:31 am, Michael Fesser <neti...@gmx.dewrote:
>.oO(gosha bine)
>Michael Fesser wrote:
>preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
>Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Micha
Where can I find a good site to explain to me all the syntax (simbols,
characters used in the preg_match function)?
php.net seems not to satisfy me.
Kudos! Now *that's* the question so many fail to ask. The detours people
will take just to avoid learning the ropes with regex, unbelievable.
It _has_ a fairly steep learning curve and a level of abstraction that
requires concentration and focus, but the merits are well worth the effort
imho.
One catch (from my own experience): try to keep an open mind as to
what solution is needed in a given situation. Some code is full of regex
fixing stuff that could (should?!) easily be dealt with using normal
string functions. Often easier to follow/adapt (for you and future editors
of your code, good documentation explaining what your regex does is key.)
and less resource-hungry. A complex regular expression can be quite taxing
on your server.
The 'best' excuse found here to avoid the matter in the NG undoubtedly
was: "I don't trust regex!".
There are several sites that offer, besides explanation, on- or offline
utilities allowing you to experiment with regex on the fly. Be aware of
the subtle dialect differences between different regex flavours though. It
may prevent you from going ape at some point...
Good luck learning regex. You'll soon reach the point where you start
wondering how you ever managed without.
Sh.
adzir wrote:
On May 8, 1:31 am, Michael Fesser <neti...@gmx.dewrote:
>.oO(gosha bine)
>>Michael Fesser wrote: preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str); Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not anchored. Use ^ and $ (and not forget /D) to make it do what you want.
Correct. Good point.
Where can I find a good site to explain to me all the syntax (simbols,
characters used in the preg_match function)?
php.net seems not to satisfy me.
http://weitz.de/regex-coach/
--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
Hi all
I have to validate a password to determine whether or not it adheres to
certain rules. For example, the password must contain at least 1 number, at
least 1 uppercase character and at...
|
by: Stirling |
last post by:
Hi all,
hope someone can help me,
I am looking to do a password validation check using client side
validation. Minimum requirement is that it must contain at least one
number and one letter. ...
|
by: Peter Rietmann |
last post by:
I have the problem to validate a password with a length of at least 6
and maximum 15 and the condition that it contains at least 2 numbers
ie.
(1aaaa1, aaaa11, 11aaaa). I am using the microsoft...
|
by: Chris Kennedy |
last post by:
Does anyone know a regular expression that will validate the file extension
but also allow multiple file extensions if necessary. It also needs to be
case insensitive. Basically, what I want is to...
|
by: Q. John Chen |
last post by:
I have Vidation Controls
First One: Simple exluce certain special characters:
say no a or b or c in the string:
*
Second One:
I required date be entered in "MM/DD/YYYY" format:
//+4 How...
|
by: JJ |
last post by:
To validate a password as the user is registering I want to use a regular
expressio validator.
I got this one from the Microsoft web site for validating a password of at
least 7 characters, with...
|
by: Geoff Berrow |
last post by:
Does anyone have a good regular expression snippet to validate usernames
and passwords?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's,...
|
by: Bob Ross |
last post by:
I am trying to validate a password field with regular expression.
the trouble is none of the ones I find on the net seem to work.
^(?=.*\d)(?=.*)(?=.*).{4,8}$
This won't allow Hello12 which it...
|
by: Andy B |
last post by:
I need to create a regular expression that will match a 5 digit number, a
space and then anything up to but not including the next closing html tag.
Here is an example:
<startTag>55555 any...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |