Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Is there a regular expressions junkie???
Old 09-22-2005, 07:31 AM Is there a regular expressions junkie???
Experienced Talker

Posts: 40
Trades: 0
Hi there!

I don't understand regular expressions ... but I have to do the following:

I have the content of a whole website in one variable called $text.
And I need to format and clean, replace some pieces of the text / code inside...

Example:

PHP Code:
$text="Hi! This is my text. Just an example. <a href='link.html'>Link</a><font size=2>Even more text</font>" 
Now I would like to clean up the text, I only need the text AND the links ... and I need to delete the rest (<font>, etc.)

How can this be done???
screamfine is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-22-2005, 11:12 AM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Will striptags() suit your needs? Just pass the string, and then pass the <a> tag as the second parameter to keep them.

PHP Code:
$txt striptags($txt'<a>'); 
Note that this doesn't clean any of the tag attributes. If you are accepting input from users, beware of mischievous uses (ie onclick's etc).
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Is there a regular expressions junkie???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31581 seconds with 12 queries