tags:

views:

119

answers:

3

i have a problem.

i what to get info about my string have ordre chater in ( a-z A-Z 0-9 and - _ ) if my string have ordre its return false or not return true.

i hob i can get help to this problem.

A: 

If I'm reading your question correctly, you want to validate if a string only contains a-z A-Z 0-9 and -_. Right?

/^[a-zA-Z0-9\-_]*$/

...should work.

Jed Smith
yes you understand my question right :) bot i don't work :/ its not validate curret. why i dont know. i hav try you and JasonWoof's answar.
NeoNmaN
this its my sample codeif ( !ereg( $this->page_shorttag , '[^a-zA-Z0-9\_-]') ) {} i use ø, æ and å to test this.
NeoNmaN
A: 

Not sure I understand your english. You want to know if it contains characters other than a-z, A-Z, 0-9, - and _?

If so, ereg($string, '[^a-zA-Z0-9_-]')

JasonWoof
ereg is deprecated, preg_* should be used instead
raspi
oh, thank you. I use ereg_replace all the time. I'll have to kick that habbit :)
JasonWoof
+1  A: 

i foundt my own way, but tanks to JasonWoof you make me on right way.

if (preg_match("/[^a-zA-Z0-9\_-]/i", $this->page_shorttag))
{
}
NeoNmaN
Why the i modifier?
Alix Axel
You're welcome. and why the backslash?
JasonWoof