Re: Checking string for invalid characters...
| From: | Stephen Hui | Date: | Thu, 06 Jul 2000 16:08:29 +0000 |
| Subject: | Re: Checking string for invalid characters... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5235@lists.php.net to get a copy of this message | ||
Regular expressions would work really well for this. Like Paolo
suggested, you should check for unallowed characters and replace them
accordingly. The ereg_replace() and eregi_replace() functions would do
this remakably well. I suggest that you familiarize yourself with
regular expressions since they come in handy in many, many other
languages (like perl and Javascript). If you need to just check for the
existance of an unallowed character, use ereg() or eregi().
I hope this helps!
Stephen.
Paolo Dell'Unto wrote:
>
> Check out the string functions section in the manual.....it should be easy
> to set up your routine. Probably instead of checking for allowed chars you
> should check for unallowed chars and evaluate the replacement of
> them....but there is a really complete set, u'll find the ones who match
> your needs.
> Ciao
> Paolo Dell'Unto
>
> At 11.30 06/07/00 -0400, you wrote:
> >Hello,
> >I was wondering if some some had a routine which would check a string for
> >invalid characters.
> >I figure the logic would be something of the following:
> >
> >The user passes me a string and I compare character by character against
> >my array of "allowed" strings. but this is a while looop with a while loop
> >and it can get kind of cumbersome.
> >
> >If any one already has a good routine or solution I would apreciate any help.
> >
> >Thanks
> >Marcelo
> >
> >PS: Please reply to my email address since my mail system cannot handle me
> >being on this list.
--
Stephen Hui, ARL:UT, Austin, Texas
Computer Terms: Programmer - A red-eyed, mumbling mammal
capable of conversing with inanimate objects.