1.

What will be the result when non greedy repetition is used on the pattern /a+?b/?(a) Matches the letter b preceded by the fewest number of a’s possible(b) Matches the letter b preceded by any number of a(c) Matches letter a preceded by letter b, in the stack order(d) Matches letter a present in the stringI got this question in an interview.The question is from Pattern Matching and Regular Expressions in portion Classes and Modules in JavaScript of JavaScript

Answer»

The correct option is (a) Matches the LETTER b preceded by the fewest number of a’s possible

The best explanation: Using NON greedy repetition may not always produce the RESULTS you expect. /a+?b/ matches the letter b preceded by the fewest number of a’s possible.



Discussion

No Comment Found

Related InterviewSolutions