在评估正则表达式之前修剪空格 [英] trim spaces before evaluating regex
本文介绍了在评估正则表达式之前修剪空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
编写验证正则表达式的正确方法是什么,以便在评估之前修剪所有前导和
尾随空格?谢谢。
What''s the proper way to write a validation regex so that all leading and
trailing spaces are trimmed before evaluation ? Thanks.
推荐答案
你可能只想在传递给正则表达式之前做一个string.Trim()。
-
William Stacey [MVP]
" John A Grandy" < johnagrandy-AT-雅虎网络泡沫>在消息中写道
新闻:eB ************** @ TK2MSFTNGP10.phx.gbl ...
You may just want to do a string.Trim() before passing to regex.
--
William Stacey [MVP]
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl...
什么是编写验证正则表达式的正确方法,以便在评估之前修剪所有前导和后退空格?谢谢。
What''s the proper way to write a validation regex so that all leading and
trailing spaces are trimmed before evaluation ? Thanks.
它位于客户端评估的验证器内。
" William Stacey [MVP]" < ST ***** @ mvps.org>在消息中写道
新闻:eS ************* @ TK2MSFTNGP11.phx.gbl ...
It''s inside a validator evaluated on the client-side.
"William Stacey [MVP]" <st*****@mvps.org> wrote in message
news:eS*************@TK2MSFTNGP11.phx.gbl...
你可能只是想做一个字符串.Trim()在传递到正则表达式之前。
-
William Stacey [MVP]
John A Grandy < johnagrandy-AT-雅虎网络泡沫>在消息中写道
新闻:eB ************** @ TK2MSFTNGP10.phx.gbl ...
You may just want to do a string.Trim() before passing to regex.
--
William Stacey [MVP]
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl...
写什么是正确的方法验证正则表达式,以便在评估之前修剪所有前导和后退空格?谢谢。
What''s the proper way to write a validation regex so that all leading and
trailing spaces are trimmed before evaluation ? Thanks.
John A Grandy写道:
John A Grandy wrote:
什么是正确的方法编写一个验证正则表达式,以便在评估之前修剪所有前导和尾随空格?谢谢。
What''s the proper way to write a validation regex so that all leading
and trailing spaces are trimmed before evaluation ? Thanks.
您可以扩展该正则表达式,以便接受前导/尾随空格。
别忘了修剪值然后才使用它。
[] *< original RE> [] *
Hans Kesting
You could extend that regex, so that leading/trailing spaces are accepted.
Don''t forget to trim the value then before you use it.
[ ]*<original RE>[ ]*
Hans Kesting
>
这篇关于在评估正则表达式之前修剪空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文