fork(1) download
  1. import re;
  2. content = ["hostname(config)#aaa new-model", "fdfsfd b", "kthik", "pooooo", "shh"]
  3. name=''
  4. found_state = 0 # Declare found_state
  5. for data in content:
  6. m = re.search(r'#(\w+)',data) # Use a raw string literal and a capturing group
  7. if m: # Check if there was a match and if yes
  8. found_state=1 # - increment found_state
  9. name=m.group(1) # - get the word after #
  10. break
  11. if found_state==1:
  12. print name + " is Found"
  13. else:
  14. print "NF"
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
aaa is Found