-1

I've been struggling all day to try and convert the following regex that works for php, into a form for javascript. I am trying to use it for some VBA where I can replace "sedol" with a variable so I can loop through the string to get "name" and other elements So for example below I would want the outcome to = '0452173'

php regex:

(?<="sedol":")(.+?)(?=",")

String extract:

"sedol":"0452173","name":"Aberdeen Japan Equity (Class I)", .....
0

1 Answer 1

0

The problem is that JS doesn't support look behind. However, you could do this:

var re = new RegExp("(?:\"" + yourVar + "\":\"(.+?)(?=\",\")");

Then use

var res = re.exec(yourString);
if (res != null) { // match
    return res[1]; // the matched part of (.+?)
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.