Info
This question is closed. Reopen it to edit or answer.
Does regexp treat metacharacters and literal characters differently when using empty lookaround operators?
1 view (last 30 days)
Show older comments
Command: regexp('2015-02-11','(?<=\d+\-)02','match','once')
ans = '02'
Command: regexp('2015-02-11','(?<=\d+\-)\d+','match','once')
ans = '02'
Command: regexp('2015-02-11','(?<=)2015','match','once')
ans = '2015'
Command: regexp('2015-02-11','(?<=)\d+','match','once')
ans = ''
The empty lookaround operator works when followed by a literal character match. And the \d metacharacter works when following a lookaround operator that isn't empty. Why then does the metacharacter fail when following an empty lookaround operator?
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!