![](/img/trans.png)
[英]How to create a for-loop that removes unwanted characters and replaces them in Python
[英]How to create Python Regex that replaces characters?
我在尋找創建適當的正則表達式的方式時遇到了麻煩,該正則表達式可以替換字符串中與z,AZ,0-9和|不同的任何內容。
到目前為止,我有:
re.sub(r'[\W_]+', '', s)
這對於字母數字字符很好用,但是我還需要使其對管道(“ |”)有效。 有人知道怎么做嗎?
例如,如果我有:
name&|surna.me|ag,e
我需要它像:
name|surname|age
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.