[advanced search]
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-11-2006, 12:02 PM   · #1
Shorty
Senior Member
 
Shorty's Avatar
 
Name: Thomas White
Location: England
Trader Rating: (15)
Join Date: Sep 2005
Posts: 1,033
NP$: 31.15 (Donate)
Shorty is just really niceShorty is just really niceShorty is just really niceShorty is just really nice
Need help using preg_replace

I'm using the following sort of PHP script to replace certain things in a given text:

Code:
$replacethis[1] = '/swear word/'; $withthis[1] = '****'; $replacethis[2] = '/different swear word/'; $withthis[2] = '****'; $name5 = preg_replace($replacethis, $withthis, $name4);


Now this works if someone enters "swear word" as name4. But the problem is, it's case sensitive...If they enter "Swear Word", "SWEAR WORD", "SwEaR WoRd" etc...it doesn't pick it up.

So basically I need a preg_replace that takes no notice of case. Is it possible, or have I gone about it the wrong way?


Please register or log-in into NamePros to hide ads
Shorty is offline   Reply With Quote
Old 04-11-2006, 12:15 PM   · #2
nasaboy007
NamePros Regular
 
Location: mysitememberships.com
Trader Rating: (32)
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (Donate)
nasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to behold
well since its just a reg exp, im pretty sure all u gotta do to make the reg exp end with i, meaning it shud be something like this

$replacethis[1] = '/swear word/i';

note the big red I
__________________
nasaboy007 is offline   Reply With Quote
Old 04-11-2006, 12:29 PM   · #3
Shorty
Senior Member
 
Shorty's Avatar
 
Name: Thomas White
Location: England
Trader Rating: (15)
Join Date: Sep 2005
Posts: 1,033
NP$: 31.15 (Donate)
Shorty is just really niceShorty is just really niceShorty is just really niceShorty is just really nice
Haha no way, that's a perfect solution...exactly what I needed!

Thank you very much.
Shorty is offline   Reply With Quote
Old 04-11-2006, 01:04 PM   · #4
sdsinc
Law and disorder
 
sdsinc's Avatar
 
Name: Kate
Location: Expat
Trader Rating: (57)
Join Date: Aug 2005
Posts: 5,481
NP$: 1585.11 (Donate)
sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute
Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV
Just on a side note if you don't require sophisticated processing with regular expressions you would be fine with str_replace in this case, and I think the function is ligther than preg_replace
sdsinc is online now   Reply With Quote
Old 04-12-2006, 01:40 PM   · #5
nasaboy007
NamePros Regular
 
Location: mysitememberships.com
Trader Rating: (32)
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (Donate)
nasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to behold
glad to be of service!
__________________
nasaboy007 is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Proof is in the Parking Hunting Moon Proof is in the Parking
Advertise your business at NamePros
All times are GMT -7. The time now is 09:06 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0