Status
Not open for further replies.

mahjong

Active Member
238
2010
14
0
Hi all!

I started to write a really small shell script, but i'm really stucked with a key part. I have a variable (multi line) and i would like to match only an url in it with regex. If i would use php, i would use preg_match. I read a lot, and found grep, which is not good for me (as i don't need the whole line), so i guess the only one working would be awk (correct me if i am wrong)

So please help me to find a regex pattern matcher in shell.


Code:
hell=<<<EOT
<script type="text/javascript" src="[URL="http://www.wjunction.com/view-source:http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"]http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js[/URL]"></script>
<script type="text/javascript" src="[URL="http://www.wjunction.com/view-source:http://www.wjunction.com/clientscript/hsjs.php"]clientscript/hsjs.php[/URL]"></script>
<link rel="stylesheet" type="text/css" href="[URL="http://www.wjunction.com/view-source:http://www.wjunction.com/clientscript/hscss.php"]clientscript/hscss.php[/URL]" />
<script type="text/javascript">hs.graphicsDir="images/highslide/";
if(hs.registerOverlay){
	hs.registerOverlay({
		thumbnailId: 'thumb2',
		html: '<div class="closebutton"	onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2
	});
}
EOT

Please grab the src=" part with shell regex into a variable (not a text file)

Thank you!
 
Status
Not open for further replies.
Back
Top