当一个正则表达式投入使用时,首先要确定目标字符串中开始搜索的位置。
When a regex is put to use, the first step is to determine the position within the target string where the search should start.
与清单1相比,在清单1中,通过选择s: name子元素,就可以立即将查找结果限制为目标字符串。
Compare this to Listing 1 where the result of key lookup is immediately narrowed down to the desired string by selecting s: name children.
目标字符串很小时,这种方法只比正则表达式快一点,但更重要的是,字符串的长度不再影响执行测试所需要的时间。
This is just a bit faster than the regex-based test with small target strings, but, more importantly, the string's length no longer affects the time needed to perform the test.
应用推荐