Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-08-2009, 08:45 PM   PM User | #1
cyberpine
New to the CF scene

 
Join Date: Oct 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
cyberpine is an unknown quantity at this point
javascript match extract of string?

Why do I get both the greedy and non-greedy? How do I extract "somestring" only? I'm on IE7.

thanks

Code:
<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>
cyberpine is offline   Reply With Quote
Old 12-09-2009, 09:03 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You were given the answer at

http://www.codingforums.com/showthread.php?t=184055
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:22 AM.


Advertisement
Log in to turn off these ads.