Regex或正则表达式是一种模式语言,用于定义不同的字符模式。Regex主要用于查找和匹配给定的模式或从文本或字符串中选择模式值。行尾(EOL)是用于指定行尾的最流行的模式之一。
null
行尾–$
行的末尾用正则表达式中的美元符号($)表示。行尾将放在regex模式的末尾,所需的模式将在$符号之前指定。行尾字符一般用于“行尾有字、字符、字符集、数字等”。
# the last character will be wisetutt$# The last word will be wisetutwisetut$# The line will end with uppercase chracters[A-Z]$# The line will end with lowercase chracters
[a-z]$
行首和行尾–^$
regex行尾字符的另一个流行用例是使用with start of the line字符。在正则表达式中,行首字符是^。我们可以使用行首和行尾字符来设置完整的线型。
# The line only contain the word "wisetut"^wisetut$# The line starts and ends with "wisetut"^wisetut.*wisetut$# The line starts with numbers and ends with letters^[0-9]*.*[a-Z]*$
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END