Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-12-2009, 04:54 PM
  #1
blackpepper
Gampi
 
blackpepper's Avatar
 
Join Date: Jul 2005
Location: metro
Posts: 1,233
iTrader: (0)
blackpepper will become famous soon enough
Regex help

Hey all,
I am in need of a regex solution to solve a problem within a database textfile I have.

I load the data file into $str via file_get_contents. What I now need to do is replace all instances of "@gmail" with "@gmail.com". However, it is not so simple because certain entries in the database have "@gmail.com" already, so for these entries, it becomes "@gmail.com.com" (obviously a problem). I think the solution is a regex with a boundary however I just am lost when it comes to this stuff.

Any help would be appreciated.
Thanks,
BP
__________________
blackpepper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-13-2009, 12:17 AM
  #2
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,242
iTrader: (0)
Horus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of light
PHP Code:
preg_replace("/@gmail$/""@gmail.com"$email); 
That $ should be enough to assert that the pattern must match the very end of the string and ignore anything like @gmail.whatever

I'd test this on a backup though if you have doubts...
__________________
Personal Blog (and photos): HorusKol
Articles on Programming and Development (PHP/HTML/CSS, C/C++, more): RandomTweak

The great secret that no SEO agent wants you to hear: if you build your website using w3c accessibility guidelines and your content is written for people, you will do better for longer in search engines than any other method...
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  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 Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 03:47 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.