| | |
preg_replace help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
What I require is to replace \/:"?<*>| with a space.
I have done similar statements before but I have complete brain freeze at the moment. Hoping one of you can jog my memory. Always hated regex expressions never understood the logic behind them minus the A-Z and 0-9 and then all the brackets, etc. Blah!
Anyways:
I have done similar statements before but I have complete brain freeze at the moment. Hoping one of you can jog my memory. Always hated regex expressions never understood the logic behind them minus the A-Z and 0-9 and then all the brackets, etc. Blah!
Anyways:
php Syntax (Toggle Plain Text)
$pattern = // This where I require the regex expression $replacement = " "; $string = "a\b/c:d*e?f"g<h>i|j"; $test_string = preg_replace($pattern, $replacement, $string); echo $test_string;
Last edited by OmniX; Jun 29th, 2009 at 3:30 pm.
"You never stop learning." - OmniX
If you want everything accept for letters and numbers you can use
If you are specific about \/:"?<*>| then it's this
php Syntax (Toggle Plain Text)
$pattern = '/[^a-z0-9]/i';
php Syntax (Toggle Plain Text)
$pattern = '#[\/:"\?<\*>|]#';
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Thanks for the solution.
If you have any good sites to refresh my memory of this stuff let me know.
Thankyou.
If you have any good sites to refresh my memory of this stuff let me know.
Thankyou.
"You never stop learning." - OmniX
•
•
•
•
Thanks for the solution.
If you have any good sites to refresh my memory of this stuff let me know.
Thankyou.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- preg_replace help (PHP)
- Converting html to bb using preg_replace (PHP)
- Replacing 2 characters with with preg_replace (PHP)
- preg_replace (PHP)
- preg_replace regular expression problem with bbcode (PHP)
Other Threads in the PHP Forum
- Previous Thread: How to buid a forum & blog app!!
- Next Thread: Background theme should be with mouse...
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary body broken cakephp checkbox class cms code cron curl database date date/time display dynamic echo email error file files folder form forms function functions global google href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail memmory menu mlm mod_rewrite msqli_multi_query multiple mycodeisbad mysql navigation oop parameter paypal pdf php problem query radio random recourse recursion regex registrationform remote script search seo server sessions sms soap source space sql static syntax system table tutorial update upload url validation validator variable video web webdesign wordpress xml youtube






