Consider this string,
var string = "sometext/#a=some_text/#b=25/moretext";
What I would like to do is extract the values of "a" and "b" ("some_text" and 25)
So essentially what I want to do is find "#a=" and grab everything before the following /, then do the same for b. How can this be accomplished? Additionally, would I use the same expression to change the values in the string?
I got a hand doing this with PHP, but now I can't figure it out for JavaScript.
Edit
Here's the PHP version of extraction:
$string = "sometext/#a=some_text/#b=25/moretext";
$expr = '@#([a-z]+)=(.+?)/@';
$count = preg_match_all($expr, $string, $matches);
$result = array();
for ($i = 0; $i < $count; $i++) {
$result[$matches[1][$i]] = $matches[2][$i];
}
print_r($result[b]);
(output would be "some_text")