Yet Another PHP REG EXP Q?
I hate to ask you guys b/c I know it gets you angry when people ask for reg exp help...hehe..I swear i'll take to the time to learn it myself in the next few days..but for now I need some quick help.
I need a way to strip out all characters except these _-[a-zA-Z0-9]
Using one of the php reg exp...i guess using the preg_replace or something similar.
Thanks,
Dave
druagord posted this at 14:23 — 6th January 2004.
He has: 335 posts
Joined: May 2003
Why do you say that reg expression are usualy challenging
preg_replace("/\W/","//",$mystring);
IF , ELSE , WHILE isn't that what life is all about
section31 posted this at 19:36 — 6th January 2004.
They have: 28 posts
Joined: May 2003
Well people normally just scuff and say learn it yourself.
\W
Matches any non-alphanumeric character; this is equivalent to the class [^a-zA-Z0-9_].
How would I go about adding - to this set of charactes. You forgot I had that in the list.
section31 posted this at 19:42 — 6th January 2004.
They have: 28 posts
Joined: May 2003
nm i firguted it out.. I forgot to esacpe the metacharacter - so thats why it wasn't working...got it working now ...thanks.
druagord posted this at 20:04 — 6th January 2004.
He has: 335 posts
Joined: May 2003
See you learned it yourself
section31 posted this at 20:38 — 6th January 2004.
They have: 28 posts
Joined: May 2003
I just need to take the time and learn this stuff...I haven't spent one second reading the documentation. I'm sure it won't take that long for me to learn it... Thanks again
m3rajk posted this at 16:50 — 13th January 2004.
They have: 461 posts
Joined: Jul 2003
fyi: leran the perl shorts. they're notrmally quite helpful. and \w is the opposite of \W ... like \d and \D are opposites and \s and \S are opposites
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.