Python正则表达式:如何忽略任何数字的特定字符串?否定前瞻

时间:2017-07-19 12:16:50

标签: python regex python-3.x regex-negation

我有以下输入

st="""
I need 2 position Urgent 400-500$. It would be a
Programmer($ 500 ~ $ 1000) or Software and Business Analyst Manager salary in range 1k-1.2k with IT Manager Urgent 900-1,000$ 3 positions 3positions 
"""

我希望只获得我在https://regex101.com/r/owE3A3/5中尝试过模式的薪水,它产生了我想要的结果,但是当我在Python上实现时,似乎无法使用Negative Lookahead表达式。这是我的代码段

pattern= re.compile(r'(?!(\d\s*?positions?))[0-9]?[0-9,.]+')
print(pattern.findall(st))
#output ['', '', '', '', '', '', '', '']

你可以给一些建议忽略具有特定字符串的数字吗?任何答案都会得到满足

0 个答案:

没有答案
相关问题