|
Posted by Good Man on 05/14/07 20:07
shimmyshack <matt.farey@gmail.com> wrote in
news:1179172003.349086.263840@e51g2000hsg.googlegroups.com:
>> just to make sure I follow... your eregi function keeps any of your
>> 'allowed' characters in your expression, and replaces everything else
>> with just a "" (blank), is that correct?
>
> yes that eregi just allows the char range, but you can specify others
> including accented chars and so on, it does as you say and replaces
> any others, so
> Go0od man->Goodman
> (as spaces arent allowed in the above ereg)
> preg_replace is generally preferred by works in a similar way.
> You can also make things more user friendly, say a user has to enter a
> britsih postcode (which has many rules for its formation) and the user
> types
> P014 instead of PO14 (zero instead of capital letter O) or doesnt use
> a space.
> P0145QL
> you can write a simple reg exp that filters chars and checks for
> comformity to rules, and makes likely replacements (like 0 and O)
> where there is no abiguity interpreting the users input, and throw out
> the result to the lookup.
> I love 'em!
Thanks for the discussion, that will be my future method for 'cleaning'
filenames and the like.
Best,
GM
Navigation:
[Reply to this message]
|