This is a discussion on string validating within the alt.comp.lang.php forums, part of the PHP Programming Forums category; hi all i need to validate a string that must contain only characters, digits and .. - _ characters hi try this ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"Josh" <josh@despammed.com> schreef in bericht news:bnto5m$15eu35$1@ID-203386.news.uni-berlin.de... > hi all > i need to validate a string that must contain only characters, digits and > . - _ characters > > hi try this but don't work > > if(!eregi("[a-z0-9_.-]",$str)) echo"error"; Try : "[a-z0-9_.-]+" (for one or more occurances) JW |
|
|||
|
*** Josh wrote/escribió (Fri, 31 Oct 2003 14:30:17 +0100):
> i need to validate a string that must contain only characters, digits and > . - _ characters > > if(!eregi("[a-z0-9_.-]",$str)) echo"error"; [a-z0-9_\.-]+ Please note '.' is wildcard for any character, you have to escape it. -- -- -- Álvaro G. Vicario - Burgos, Spain -- |
|
|||
|
"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> schreef in bericht news:dps8u5o3l42p$.100sl6dzo15ux.dlg@40tude.net... > > [a-z0-9_\.-]+ > > Please note '.' is wildcard for any character, you have to escape it. > True, when the next character is a + or an *. As with the -, its use is depending on its position within the character class. JW |
|
|||
|
On 3-Nov-2003, "Janwillem Borleffs" <jw@jwscripts.com> wrote: > "Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> schreef > in > bericht news:dps8u5o3l42p$.100sl6dzo15ux.dlg@40tude.net... > > > > [a-z0-9_\.-]+ > > > > Please note '.' is wildcard for any character, you have to escape it. > > > > True, when the next character is a + or an *. As with the -, its use is > depending on its position within the character class. Inside a character class a . matches only a period. Outside a character class it matches any single character execpt newline. It may be modified by + or *, but they are not required. In the case above it matches only a period with or without the backslash. -- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to jamesbutler@willglen.net (it's reserved for spammers) |
![]() |
| Thread Tools | |
| Display Modes | |
|
|