Re: eregi

From: Date: Tue, 02 Oct 2001 04:06:18 +0000
Subject: Re: eregi
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69536@lists.php.net to get a copy of this message
i realize a solution using strspn/strcspn was offered, but you asked for eregi :) anyway, i use ereg, but i think this should work eregi("^[a-z0-9_\-]+$",$string) notice that i had to escape the dash with a backslash the plus sign forces atleast one character. you can use {x,y} in place of the plus to force atleast x characters but no more than y characters. mike on 10/1/01 4:53 PM, Tim Ballantine at pot.noodle@blueyonder.co.uk wrote: > Thankyou... > > I should have made it clearer that I did want to use only the legal > characters to compare the string by. > > Tim > > "Rasmus Lerdorf" <rasmus@php.net> wrote in message > news:Pine.LNX.4.33.0110011539240.1241-100000@rasmus.php.net... >> Well, either you need to know the valid chars or the invalid ones. Make >> up your mind and use strspn() or strcspn() appropriately. >> >> -Rasmus >> >> On Mon, 1 Oct 2001, Tim Ballantine wrote: >> >>> "Returns the length of the initial segment of str1 which does not > contain >>> any of the characters in str2." >>> >>> I realise that i could see if this matches with the length of the entire >>> word, and is there a way to get it to compare the word by the legal >>> characters, because the amount of illegal symbols, including different >>> language symbols (french for example) will be too high for me to list. >>> >>> Tim >>> >>> "Rasmus Lerdorf" <rasmus@php.net> wrote in message >>> >>> news:Pine.LNX.4.33.0110011533350.1241-100000@rasmus.php.net... >>>> Huh? You better read that documentation page again. You only need to >>>> list the illegal symbols. And what do you mean by length? >>>> >>>> -Rasmus >>>> >>>> On Mon, 1 Oct 2001, Tim Ballantine wrote: >>>> >>>>> Is there anything which doesnt use length? And something like eregi, >>> because >>>>> it would be infeasible to list all of the symbols that a user could > use, >>> to >>>>> compare a string by. >>>>> >>>>> Tim >>>>> >>>>> "Rasmus Lerdorf" <rasmus@php.net> wrote in message >>>>> >>>>> news:Pine.LNX.4.33.0110011523560.1241-100000@rasmus.php.net... >>>>>> See php.net/strcspn >>>>>> >>>>>> On Mon, 1 Oct 2001, Tim Ballantine wrote: >>>>>> >>>>>>> Hello, >>>>>>> >>>>>>> Could anyone tell me how to eregi a word, to see if it only > contains >>>>> either >>>>>>> numbers, letters, the "_" and the "-", so that any >>>>>>> other symbol > with >>>>> call it >>>>>>> invalid. For example, theres the word "expressio_n" that will >>>>>>> be >>> valid, >>>>> but >>>>>>> the word "express%^$-n" will be invalid. >>>>>>> >>>>>>> Thankyou, >>>>>>> >>>>>>> Tim >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>> >>> >>> >>> >> >> > > -- mike cullerton

« previous php.general (#69536) next »