這可能是一個轉儲問題。但我必須要求澄清它。正則表達式差異+和*
我有一個文本
string = ''' t Network Questions
Is there something like a (readied) charge in 5e?
Can you use a
Bonus Action on a turn'''
文本被有意分散。我偶然發現了這個疑問。
print re.sub(r'\s+',' ',string)
t Network Questions Is there something like a (readied) charge in 5e? Can you use a Bonus Action on a turn
看看下一條語句。
print re.sub(r'\s*',' ',string)
t N e t w o r k Q u e s t i o n s I s t h e r e s o m e t h i n g l i k e a (r e a d i e d) c h a r g e i n 5 e ? C a n y o u u s e a B o n u s A c t i o n o n a t u r n
唯一的區別是*和+。那麼,到底什麼意思是0或更多的出現和更多的出現。任何人都可以解釋爲什麼當我們使用*時,單詞之間的空格。
這是任何人都可以給出的最好解釋。它的好答案很好地解釋了。 – user3116355
謝謝!!! :) – nu11p01n73R