import retest_str = "4.7pF\n16.2kΩ\n22.6nH" result = re.sub(r'(\d+)(?:\.(\d+))(\w).*', r"\1\3\2", test_str).upper()print(result)
Standard input is empty
4P7 16K2 22N6
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!