import rep = re.compile(r'\[(\d+)\|([^][]*)]')test_str = "Text [123|Foo bar] text"print (p.findall(test_str))
Standard input is empty
[('123', 'Foo bar')]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!