Topic: how to cut a certain group of words in a string? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30657" title="Pages that link to Topic: how to cut a certain group of words in a string? (Page 1 of 1)" rel="nofollow" >Topic: how to cut a certain group of words in a string? <span class="small">(Page 1 of 1)</span>\

 
eagle_eye
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Nov 2008

posted posted 11-17-2008 14:49

Hello there,
how to cut a certain group of words in a string, for example,
"<img src='images/smiles/grin.gif' smilietext=':grin:' border='0' style='vertical-align:middle' alt=':grin:' title=':grin:' />"
"<img src='images/smiles/smile.gif' smilietext=': smile:' border='0' style='vertical-align:middle' alt=': smile:' title=': smile:' />"
?..
from a forum comment.

I tried this:
$subject =$row_Recordset2['pagetext']
$pattern="/<img src='images\/smiles\/[a-zA-Z]+\.gif' smilietext=':[a-zA-Z]:' border='0' style='vertical-align:middle' alt=':[a-zA-Z]:' title=':[a-zA-Z]:' \/>/";
$result = preg_replace($pattern,"",$subject);
But I failed, I am new to PHP, please help. Thanks very much in advance.

eagle_eye
Obsessive-Compulsive (I) Inmate

From:
Insane since: Nov 2008

posted posted 11-17-2008 14:51

logically, is it a better way to search for all what is inside the <img ... /> tag (including numbers) and replace them with ""?
I will write: $pattern="/<img [a-zA-Z][0-9]>\/>/", is it correct? Thank you for your help.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 11-18-2008 17:31

but what would you do with an empty <img>?
Please, explain again in detail: what do your strings look like before,
what should the look like after, and what information do you want to extract into seperate variables?
And can you have more than one occurance in a string?



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu