954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to make Regex to capture this code?

Dear Buddies,

Need your help to make a simple regex to grab all codes from

I would like capture this code for deleting in Yahoo pipes.

code:

<!-- Begin Code -->
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '132829708015487', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>


	
		
		
		
	
				


<ul id="socialTools">
<li class="twitter">

<script type="text/javascript">
tweetmeme_style = 'compact';
</script>
<script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>
</li>
<li class="digg">

<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<a href="http://digg.com/></a>
</li>
<li class="buzz">

<span>
<a title="Post on Google Buzz" class="google-buzz-button"></a>
<script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>
</span>
</li>
<li class="facebook">

<fb:like href="" />
</li>
</ul>

<div style="clear: both;"></div>
<!-- End Code -->


Thanks for your kind help.

Best Regards,

reborn2010
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 
if (preg_match('/<!-- Begin Code -->(.*?)<!-- End Code -->/s', $subject)) {
	# Successful match
} else {
	# Match attempt failed
}
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
if (preg_match('/<!-- Begin Code -->(.*?)<!-- End Code -->/s', $subject)) {
	# Successful match
} else {
	# Match attempt failed
}


Thanks for your kind help, but I'm very dumb about this. I tried this in gskinner.com, but I can't find the capturing result. Can you give an example code that I must fill in 1stbox of gskinner.com, to get a capturing result?

Many thanks and best regards.

reborn2010
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

If you want to delete the text from the stream but still have the contents. I simulated the feed with a file from your code that I made called subject.php.

<body>
<?php
$subject = file_get_contents('subject.php');
$mark=preg_replace('/<!-- Begin Code -->(.*?)<!-- End Code -->/s', $subject,'');
echo("Mark is ".$mark."" .$subject);
?>
</body>
</html>
tinymark
Junior Poster
158 posts since Feb 2010
Reputation Points: 11
Solved Threads: 17
 

Your regex contains spaces, and may not work. The space may not be there.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

You know, I didn't check that. I just used his file. Life becomes very different when the script goes live. Who knows whether all the pages are exactly the same(made with a template) or not. One example does not make a regex as you point out. Did you try his code @pritaeas?

tinymark
Junior Poster
158 posts since Feb 2010
Reputation Points: 11
Solved Threads: 17
 

pritaeas and tinymark, thanks for your kind help.. I'm still confuse to apply it in Yahoo Pipe... usually I use hxxp://gskinner.com/RegExr/

regards,

reborn2010
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

I think I get the whole picture now. Pipes allow you to select a lot of different news feeds and process them with their filters. The whole mess gets put together into a personalized feed that would be a clickable thing if I had an account and was at the site. You want to setup your pipes at Yahoo because you have an account and want to use Ajax, PHP something to go get the feed information and save it to a variable in your program. Then you want to apply some local filters to get rid of the stuff you have downloaded that you don't want to see. Now ask me if I use news feeds.:P

In jquery I would go something like this.

$.post('http://pipes.yahoo.com/pipes/pipe.run?_id=Kt...y0Q&_render=rss&_run=1&locationinput1=richmond%2C+va', function(data){
if (data) var my_data = data;
further_processing(data); });
function further_processing(data){
'finish the processing with a regex'
}

I hope that helps. Didn't know a thing about them before I started. Some of the people I know kid me about not using news readers.

tinymark
Junior Poster
158 posts since Feb 2010
Reputation Points: 11
Solved Threads: 17
 
I think I get the whole picture now. Pipes allow you to select a lot of different news feeds and process them with their filters. The whole mess gets put together into a personalized feed that would be a clickable thing if I had an account and was at the site. You want to setup your pipes at Yahoo because you have an account and want to use Ajax, PHP something to go get the feed information and save it to a variable in your program. Then you want to apply some local filters to get rid of the stuff you have downloaded that you don't want to see. Now ask me if I use news feeds.:P

That's right, I would delete all code as above. The problem is that I failed to capture all code from to .. :) Thanks

reborn2010
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: