Possible to run a regex from within a sql query?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Possible to run a regex from within a sql query?

Post by Burrito »

I have some content from an LMS here that has our old domain in it that I need to just replace with our new domain (for img references and hrefs).

is it possible to do a "search" on the table field for the old domain and replace it with the new domain?

my alternative is to export the data, open a text editor and do a find and replace there, then re-import the data.

I'd like to avoid that if possible.

Burr
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what's wrong with writing a bit of a script to search the table, then update each record found updating the table as it goes?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

yes thought about that after I posted.

gonna give that a go...

thx,

Burr
jonemo
Forum Commoner
Posts: 28
Joined: Wed Feb 09, 2005 1:32 pm
Location: london, uk

Post by jonemo »

you can use REGEXP() in where statements. however you cannot use something like [p/e]reg_replace on the database.
Post Reply