Originally posted by YoDe at 2008-7-15 22:36:
\<代表一个单词的前边界,而\>代表一个单词的后边界 至于这句 我无法理解
举个简单的例子吧!
比如现在有一个字符串,不含两边的中括号,那么
"\<it" 就可以匹配this后面的is这个单词,而this这个单词里面包含的is就无法匹配,因为表达式"\<it"前面的\<符号要求这个it左边是空格或者其它的字符,不能是字母,下划线和任何组成单词的字符,所以这里的this里面的is是无法匹配表达式的,\<表示的只是一个位置,这个位置前面是非单词字符,后面是单词字符,\>则和它相反。
什么是单词字符呢?
a-z,A-Z,_,0-9都可以是组成单词的字符,其它的就不是单词字符了,比如符号~!@#$%^&*()_+ …… 这些都不是。
你可以网上搜搜关于正则表达式的文章。
Originally posted by YoDe at 2008-7-15 22:36:
\< represents the front boundary of a word, and \> represents the back boundary of a word. As for this sentence, I can't understand it.
Let's give a simple example!
For example, there is a string now, excluding the square brackets on both sides, then
"\<it" can match the word "is" after "this", but the "is" contained in the word "this" cannot be matched, because the "\<" symbol in the expression "\<it" requires that the left side of this "it" is a space or other characters, not letters, underscores, and any characters that make up a word. So the "is" in "this" cannot match the expression. \< only represents a position, where the front is a non-word character and the back is a word character, and \> is the opposite of it.
What are word characters?
a-z, A-Z, _, 0-9 can all be characters that make up a word, and others are not word characters. For example, symbols ~!@#$%^&*()_+... These are not.
You can search for articles about regular expressions on the Internet.