Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

regex-lookarounds - 意外的\ W? 正则表达式环顾的行为(Unexpected W? behavior with regex lookaround)

In a simple regex I want to match segments where "1 is not followed by 'a', possibly preceded by whitespaces", '1' may be followed by a nonword character (such as ",").

(在一个简单的正则表达式中,我要匹配以下段:“ 1后面不跟'a',可能后面跟空格”,'1'后面跟一个非单词字符(例如“,”)。)

1\W(?!\s a) functions correctly (on test strings "1 a" and "1, a") 1\W?(?!\s a) does not function correctly.

(1 \ W(?!\ s a)正常运行(在测试字符串“ 1 a”和“ 1,a”上)1 \ W?(?!\ s a)正常运行。)

What is the explanation for this?

(这有什么解释?)

  ask by TonyR translate from so

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

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...