string validating

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2003
Josh
 
Posts: n/a
Default string validating

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";
Reply With Quote
  #2 (permalink)  
Old 10-31-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: string validating


"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



Reply With Quote
  #3 (permalink)  
Old 11-03-2003
Alvaro G Vicario
 
Posts: n/a
Default Re: string validating

*** 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
--
Reply With Quote
  #4 (permalink)  
Old 11-03-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: string validating


"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



Reply With Quote
  #5 (permalink)  
Old 11-03-2003
Tom Thackrey
 
Posts: n/a
Default Re: string validating


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)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0