File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 498
498
<p >我希望现在你能明白,我为什么让你特别注意反斜杠。</p >
499
499
<h3 ></h3 >
500
500
<h3 >动态正则表达式</h3 >
501
- <p >当你动态创建一个正则表达式的时候请特别小心。如果你使用的字符串不够完善的花 ,可能会有意想不到的匹配结果。这可能导致语法错误,更糟糕的是,你的正则表达式语法正确,但是结果无法预料。</p >
501
+ <p >当你动态创建一个正则表达式的时候请特别小心。如果你使用的字符串不够完善的话 ,可能会有意想不到的匹配结果。这可能导致语法错误,更糟糕的是,你的正则表达式语法正确,但是结果无法预料。</p >
502
502
<p >错误的Java代码:</p >
503
503
<p >String sep = System.getProperty(“ ; file.separator” ; ); String[] directories = filePath.split(sep);</p >
504
504
<p ><span style =" font-family : Tahoma ;" >Bug:</span ><span style =" color : #0000ff ;" >String.split() </span ><span style =" font-family : Tahoma ; font-size : medium ;" >认为sep是一个正则表达式。但是,在Windows中,Sep是表示匹配一个反斜杠,也就是与正则表达式” ; \\” ; 相同。这个正则表达式是正确的,但是会返回一个异常:</span ><code >PatternSyntaxException</code >.</p >
586
586
<h3 > 致谢</h3 >
587
587
<p >正则表达式非常常用而且非常有用。每个人在编辑文本或是编写程序时都必须了解怎样使用正则表达式。</p >
588
588
<h4 ><strong >练习</strong ></h4 >
589
- <h4 >选择正则表达式的某种实现,阅读相关文档。我保证,你会学到更多。</h4 >
589
+ <h4 >选择正则表达式的某种实现,阅读相关文档。我保证,你会学到更多。</h4 >
You can’t perform that action at this time.
0 commit comments