![](/img/trans.png)
[英]Extract all strings in between between all same pairs of the two string using regex or python functions
[英]Extract all the char between 2 strings using regex in Python
我想問一些關於Python中的正則表達式的問題。
在變量nihao中,有一個類似以下的字符串:
Committee Members: Prof.A (Supervisor)
我想提取Prof.A(僅Prof.A,消除所有\\ t或其他空白)
委員會成員:
和
(主管)python語言。
我應該如何編寫正則表達式?
謝謝。
只需幾處修改:
Committee\sMembers:\s+([\w.\s]+)\s\(Supervisor\)
在這里看: http : //regex101.com/r/pS9bQ9/4
注意:下次,regex101.com是測試您regex的好網站
稍微擴展@VincentBeltman的正則表達式,也可以像這樣完成-
# Committee\s+Members:\s*(\w[\w.\s]*?)\s*\(Supervisor\)
Committee \s+ Members:
\s*
( \w [\w.\s]*? ) # (1)
\s*
\(Supervisor\)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.