Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple help with expressions comparing 2 conditions 1

Status
Not open for further replies.

TurboSRT4

Programmer
Nov 23, 2009
47
0
0
US
hi I have this
if ($first =~ /\d{1,}/{
die;
}

how could i compare 2 or 3 at the same time like if $first contains a numeral or if $first contains an @ or if $first contains a period.

thanks guys.
 
Thanks a lot i have this following code which is returning errors if it contains a number? can someone show me the fix and expliain it please thank you
 
lol sorry this should help

if ($passwor =~ /[\\\/~`@#\$\%^&*()-_\+\=\[\{\]\}\|\"\']/){
push @errors, qq(Password Is Invalid<BR>);
}
 
Hi

TurboSRT4 said:
i have this following code which is returning errors if it contains a number?
Sorry, I not understand that sentence. Just that you want something with numbers. As that character class not contains numbers, I suppose you want it to contain :
Code:
[b]if[/b] [teal]([/teal][navy]$passwor[/navy] [teal]=~[/teal] [green][i]/[[highlight]\d[/highlight]\\\/~`@#\$%^&*()-_+=\[{\]}|"']/[/i][/green][teal])[/teal][teal]{[/teal]
  [b]push[/b] [navy]@errors[/navy][teal],[/teal] [b]qq[/b][green][i](Password Is Invalid<BR>)[/i][/green][teal];[/teal]
[teal]}[/teal]
Anyway, your request is strange. On some machines is mandatory to have digits and/or signs in the password.

Feherke.
 
No, i want numbers and letters only no spaces or special characters
thank you
 
Hi

TurboSRT4 said:
i want numbers and letters only
Then say it like that. Is shorter than enumerating all forbidden characters. By the way, your previous regular expression allows punctuations : dot ( . ), comma ( , ), colon ( : ), semicolon ( ; ), exclamation mark ( ! ), question mark ( ? ). Also note that french quotes ( « » ) are also allowed. And although you disallow dollar sign ( $ ), you still allow cent ( ¢ ), euro ( € ), pound ( £ ), yen ( ¥ ), etc.
Code:
[gray]# allow word characters ( letters, digits and underscore )[/gray]
[b]if[/b] [teal]([/teal][navy]$passwor[/navy] [teal]!~[/teal] [green][i]/^\w+$/[/i][/green][teal])[/teal][teal]{[/teal]
  [b]push[/b] [navy]@errors[/navy][teal],[/teal] [b]qq[/b][green][i](Password Is Invalid<BR>)[/i][/green][teal];[/teal]
[teal]}[/teal]

[gray]# allow alphanumeric characters ( letters, digits )[/gray]
[b]if[/b] [teal]([/teal][navy]$passwor[/navy] [teal]!~[/teal] [green][i]/^[[:alnum:]]+$/[/i][/green][teal])[/teal][teal]{[/teal]
  [b]push[/b] [navy]@errors[/navy][teal],[/teal] [b]qq[/b][green][i](Password Is Invalid<BR>)[/i][/green][teal];[/teal]
[teal]}[/teal]

[gray]# allow the mentioned characters case insensitively[/gray]
[b]if[/b] [teal]([/teal][navy]$passwor[/navy] [teal]!~[/teal] [green][i]/^[a-z0-9]+$/[/i][/green][b]i[/b][teal])[/teal][teal]{[/teal]
  [b]push[/b] [navy]@errors[/navy][teal],[/teal] [b]qq[/b][green][i](Password Is Invalid<BR>)[/i][/green][teal];[/teal]
[teal]}[/teal]

Feherke.
 
Hey thanks for your help man! your solution will not falter with case sensitivity?
 
feherke, is there also a way to push the error if the field is blank without adding a seperate if statement thank you
 
Hi

TurboSRT4 said:
Hey thanks for your help man! your solution will not falter with case sensitivity?
All three expressions allow both lowercase and uppercase characters.
TurboSRT4 said:
feherke, is there also a way to push the error if the field is blank without adding a seperate if statement thank you
All three expressions require at least one character.


Feherke.
 
little more help please :)

I am printing user info to file and have the following

print USERS "\n$usernxx$passworxxuserxx$streetxx$cityxx$statexx$zipxx$phonexx$faxxx$emailxx$company";

the problem here is obvious, but i need the string printed with no spaces for instance $usern name is testUser and $passwor is testPass

i need it to print to file like this testUserxxtestPass but if i put a space after each variable it prints the space.. please help and thanksin advance
 
Hi

Code:
[b]print[/b] USERS [green][i]"\n$[highlight]{[/highlight]usern[highlight]}
[/highlight]xx$[highlight]{[/highlight]passwor[highlight]}
[/highlight]xx$[highlight]{[/highlight]user[highlight]}
[/highlight]xx$[highlight]{[/highlight]street[highlight]}
[/highlight]xx$[highlight]{[/highlight]city[highlight]}
[/highlight]xx$[highlight]{[/highlight]state[highlight]}
[/highlight]xx$[highlight]{[/highlight]zip[highlight]}
[/highlight]xx$[highlight]{[/highlight]phone[highlight]}
[/highlight]xx$[highlight]{[/highlight]fax[highlight]}
[/highlight]xx$[highlight]{[/highlight]email[highlight]}
[/highlight]xx$company"[/i][/green][teal];[/teal]

Feherke.
 
Hi

Code:
[b]print[/b] USERS [green][i]"\n"[/i][/green][teal],[/teal]
[navy]$usern[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$passwor[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$user[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$street[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$city[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$state[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$zip[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$phone[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$fax[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$email[/navy][teal],[/teal][green][i]'xx'[/i][/green][teal],[/teal]
[navy]$company[/navy]"[teal];[/teal]

Code:
[b]print[/b] USERS
[green][i]"\n"[/i][/green][teal],[/teal][b]join[/b] [green][i]'xx'[/i]
[/green][teal],([/teal][navy]$usern[/navy][teal],[/teal]
[navy]$passwor[/navy][teal],[/teal][navy]$user[/navy][teal],[/teal]
[navy]$street[/navy][teal],[/teal][navy]$city[/navy][teal],[/teal]
[navy]$state[/navy][teal],[/teal][navy]$zip[/navy][teal],[/teal]
[navy]$phone[/navy][teal],[/teal][navy]$fax[/navy][teal],[/teal]
[navy]$email[/navy][teal],[/teal][navy]$company[/navy][teal]);[/teal]

Feherke.
 
ok thanks a lot man you were great help to me today i knew how to accomplish my last issue but in a very long format :) thanks so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top