[英]python REGEX - How Do I remove Square brackets from string?
A = """ This is my [name Duty subjected to solve - time situation ] and finally I called "the man \fjd " so you take of care of that thing. """ A = """ 这是我的 [name duty 受到解决时间的情况],最后我叫了 "man \fjd" 所以你照顾那个东西。"""
This is an random string probably similar to my problem.这是一个随机字符串,可能类似于我的问题。
I wanted to output like this我想像这样 output
[name Duty subjected to solve - time situation ### Without square brackets but using finditer in python aslo I need solution for [名称职责受到解决 - 时间情况###没有方括号但在 python 中使用finditer我也需要解决方案
the man \fjd ### material inside bracket using re.finditer....括号内的 man \fjd ### 材料使用 re.finditer ....
a= """This is my [name Duty subjected to solve - time situation ] and finally I called "the man \fjd " so you take of care of that thing."""
pattern =''' I nEDD THIS ANSwers '''
for item in finditer(pattern ,a, re,VERBOSE :
return(item.groupdict())
Why do you need regex just to remove the square brackets?为什么只需要正则表达式来删除方括号? You can simply use replace to get the job done!
您可以简单地使用替换来完成工作!
a = a.replace('[', '').replace(']', ''])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.