[UPHPU] Re: explode with more than one delimiter?

Velda velda at novapages.com
Wed Dec 17 20:38:38 MST 2008


Kirk Cerny wrote:
> preg_replace
> http://us.php.net/preg_replace


Thanks Kirk.  I really need to get better at this stuff.

In case anyone else comes across this archive,  I decided to do the 
grunt work with a series of mysql replaces.  This was to fix broken 
images I had after importing to Wordpress from Nucleus.

UPDATE wp_posts  SET post_content=replace(post_content,'<%image(','<img 
src="/media/');
UPDATE wp_posts  SET post_content=replace(post_content,')%>','" />');

/* Here's where it got ugly - had to put in all the image sizes I could 
think of and find, but I wasn't sure how else to go about it.. */

UPDATE wp_posts SET post_content=replace(post_content,'|300|225|','" 
width="300" height="225" title="');
UPDATE wp_posts SET post_content=replace(post_content,'|300|300|','" 
width="300" height="300" title="');
UPDATE wp_posts SET post_content=replace(post_content,'|300|400|','" 
width="300" height="400" title="');
UPDATE wp_posts SET post_content=replace(post_content,'|200|150|','" 
width="200" height="150" title="');
UPDATE wp_posts SET post_content=replace(post_content,'|98|98|','" 
width="98" height="98" title="');



Velda wrote:
> D'oh!  Hate it when I accidentally hit send prematurely!  No spell 
> check or anything... Retract, retract!
>
> Anyway, that's what my ugly data looks like.  I need to fix all of 
> those instances so they look like regular xhtml image tags, and leave 
> the rest of my data intact, and I'm not sure how to go about it.  But 
> I'm guessing I first have to find each instance of <%, then explode 
> that out into pieces with | as the delimiter.  And then echo back the 
> right syntax, and somehow get it all back in. And I was initially 
> going to just run this directly on a .sql file itself, but I'm 
> supposing that's the dumb way to do it too.
>
> I am willing to experiment till the cows come home, but I'm not sure 
> where to start.  Can anyone give me a pointer? (Like a url?)
>
> -Velda
>
>
>
>
> Velda wrote:
>> I'm so incredibly out of my element on this.  I've got a database 
>> table filled to the brim with data looking like this
>>
>> blah blah blah <%image(someimage.jpg|300|225|some image caption)%>  
>> blah blah blah
>>
>> blah blah blah <%image(someimage.jpg|300|225|some image caption)%>  
>> blah blah blah
>>
>>
>>
>
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>



More information about the UPHPU mailing list