1

I need to parse expression like 'a' 'b' 'cd ef' three tokens how can this be done in javascript?par

2
  • 2
    Can you expand upon your question a bit? What are you trying to parse, and what would you like to end up with? Four spaces at the beginning of a line makes a code indent. Commented Nov 17, 2009 at 5:30
  • Maybe he is trying to split the string into tokens? Commented Nov 17, 2009 at 5:34

1 Answer 1

1
var re = /'([^']*)'/g;
var input = "'foo' 'bar' 'omg wtf'";
var hit;
while (hit = re.exec(input)) {
    print(hit[1]);
}
Sign up to request clarification or add additional context in comments.

1 Comment

Note however, that this simple snippet does not account for escaped quotes inside the tokens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.