| | |
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 |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube






