fork download
  1. import re
  2. texts = ['config.hello.world','config.hello','config.hello','config.hello.world']
  3. rx = re.compile(r'\bconfig\.([\w.]+)(?![(\w])')
  4. for text in texts:
  5. m = rx.search(text)
  6. if m:
  7. print(text + " => " + m.group(1))
  8. else:
  9. print(text + " => NO MATCH")
Success #stdin #stdout 0.03s 9588KB
stdin
Standard input is empty
stdout
config.hello.world => hello.world
config.hello => hello
config.hello => hello
config.hello.world => hello.world