Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

regex - 如何匹配除特定字符以外的任何非空白字符?(How to match any non white space character except a particular one?)

In Perl \S matches any non-whitespace character.

(在Perl中\S匹配任何非空白字符。)

How can I match any non-whitespace character except a backslash \ ?

(我如何匹配除反斜杠\之外的任何非空白字符?)

  ask by Lazer translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use a character class :

(您可以使用字符类 :)

/[^s\]/

matches anything that is not a whitespace character nor a \ .

(匹配不是空格字符也不是\ 。)

Here's another example:

(这是另一个例子:)

[abc] means "match a , b or c ";

([abc]意思是“匹配abc ”;)

[^abc] means "match any character except a , b or c ".

([^abc]意思是“匹配除abc以外a任何字符”。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...