...

View Full Version : javascript match extract of string?



cyberpine
12-08-2009, 08:45 PM
Why do I get both the greedy and non-greedy? How do I extract "somestring" only? I'm on IE7.

thanks



<script type="text/javascript">
var x = "(EVAL)(H:somestring)Some other Text here";
var full =(x.match(/\(H\:(.*?)\)/g)); // produces "(H:somestring)" as expected
alert(full);
var inside = (x.match(/\(H\:(.*)\)/)); // produces "(H:somestring),somestring" .. I only

want "somestring"
alert(inside);
</script>

Philip M
12-09-2009, 09:03 AM
You were given the answer at

http://www.codingforums.com/showthread.php?t=184055



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum