Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在以下几行中,如何编写正则表达式来查找一行是以货币开头还是以货币结尾
line = ["$20 is your bill", "this is your bill", "bill amount is $30", "$40 or $50"] for l in line: matchObj = re.search( r'\$[\d.]+', l, re.M|re.I)
如何检查一行是否以货币开头或结尾?
^\$\d+.*|.*\$\d+$
似乎为我工作。
但是,如果货币不是整数值,这将不起作用。