OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'util.dart'; |
| 6 import 'package:expect/expect.dart'; |
| 7 |
| 8 void main() { |
| 9 description( |
| 10 'Test regular expression processing with alternatives.' |
| 11 ); |
| 12 |
| 13 var s1 = "<p>content</p>"; |
| 14 shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))")), ["<p>","p
>",null,null,"p>","p"]); |
| 15 shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))")), ["
<p>","p>",null,null,null,"p>","p"]); |
| 16 shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|.+?)>")), ["<p>","p"]); |
| 17 |
| 18 // Force YARR to use Interpreter by using iterative parentheses |
| 19 shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|((([^>])+)>))")), ["<p>",
"p>",null,null,"p>","p","p"]); |
| 20 shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|((([^>])+)>))")),
["<p>","p>",null,null,null,"p>","p","p"]); |
| 21 shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|(.)+?)>")), ["<p>","p","p"]); |
| 22 |
| 23 // Force YARR to use Interpreter by using backreference |
| 24 var s2 = "<p>p</p>"; |
| 25 shouldBe(firstMatch(s2, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))\5")), ["<p>p"
,"p>",null,null,"p>","p"]); |
| 26 shouldBe(firstMatch(s2, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))\6")),
["<p>p","p>",null,null,null,"p>","p"]); |
| 27 shouldBe(firstMatch(s2, new RegExp(r"<(a|\\/p|.+?)>\1")), ["<p>p","p"]); |
| 28 } |
OLD | NEW |