import rep = re.compile("[0-9]*(?:\\.[0-9]+)?[^0-9]*D\\([MW]\\)\\s*US")test_str = "9.5 D(M) US"print re.search(p, test_str).group()
Standard input is empty
9.5 D(M) US
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!