我也有類似像如何用連字符中的空格替換連字符( - ),而字符串中的匹配模式除外?
text='Studied b-tech from college in 2010-13'
text.replace('-',' ')
字符串這會給
Studied b tech from college in 2010 13
我想是這樣的:
Studied b tech from college in 2010-13
我已經準備下面的圖案爲grepping像2010-13但令牌我如何在我的代碼中使用它?
regex_pattern='(\d{4}-\d{2,4})'
https://docs.python.org/3/library/re.html –
你知道'text.replace ('b-tech','b tech')'?或者是否有更多需要更換的輸入?像2010-13的一切一樣? – Neil