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
regular expressions problem
Old 07-08-2009, 06:10 AM regular expressions problem
Junior Talker

Posts: 1
Name: Avi
Trades: 0
hey,
i'm trying to convert some special combination to images...

it's my first time i'm try to use regular expressions...

for example, assume that the var $txt contain this:
Code:
<p>
sad <{img_2}> asd
</p>


i want the output will be 2
i want all the content that comes before and after the number 2 will removed...
and its important to me to replace the "<" and ">" with "&lt;" and "&gt;"

i tried this:
Code:
$img_id = preg_replace("/^(.+?)\&lt;{img_(.+?)\}&gt;(.+?)\$/", "\\2", $txt );
but its wont work!

thanks!

***sorry for poor english***
aviavi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-08-2009, 09:59 AM Re: regular expressions problem
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Why would you care if html is converted to entities if it's being ignored?

PHP Code:
// Use if you want to convert html entities
$txt htmlentities($txt);
$img_id = (int)preg_replace('/(<|&lt;){img_(\d+)}(>|&gt;)/i''$2'$txt1); 
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to regular expressions problem
 

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.15028 seconds with 12 queries