fork download
  1. import re
  2. p = re.compile(ur'^#define\s+(\w+)\s+((?:test_0x[0-9a-f]+_[a-z0-9]+\s+or\s+)?\(?test_0x[0-9a-f]+_[a-z0-9]+\)?)', re.IGNORECASE | re.MULTILINE)
  3. s = u"#define varName test_0x5F_u8 or (test_0x5F_u8)\n#define varName (test_0x5F_u8)\n#define varName test_0x5F_u8"
  4. print([x for x in p.findall(s)])
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
[(u'varName', u'test_0x5F_u8 or (test_0x5F_u8)'), (u'varName', u'(test_0x5F_u8)'), (u'varName', u'test_0x5F_u8')]