fork download
  1. import re
  2.  
  3. regex = r"-x ([\"'])(\w+)\1"
  4.  
  5. test_str = ("00 04 * * 2-6 testuser /get_results.sh -q -x 'igp_srm_m' -s 'yesterday' -e 'yesterday' -m '2048' -b >>'/var/log/process/srm-console.log' 2>&1\n"
  6. "00 10 * * 2-6 testuser /get_results.sh -q -x 'igp_srm_m' -s 'yesterday' -e 'yesterday' -m '2048' -w '720' >>'/var/log/process/srm-console.log' 2>&1\n\n"
  7. "00 08 * * 1-5 testuser /get_results.sh -q -x \"igp_france\" -s \"today\" -e \"today\" -m \"90000\" -b -z partA >>\"/var/log/process/france-partA-console.log\" 2>&1\n"
  8. "00 12 * * 2-6 testuser /get_results.sh -q -x \"igp_france\" -s \"yesterday\" -e \"yesterday\" -m \"90000\" -w \"900\" -z partA >>\"/var/log/process/france-partA-console.log\" 2>&1\n\n"
  9. "00 08 * * 1-5 testuser /get_results.sh -q -x \"igp_france\" -s \"today\" -e \"today\" -m \"90000\" -b -z partB >>\"/var/log/process/france-partB-console.log\" 2>&1\n"
  10. "00 12 * * 2-6 testuser /get_results.sh -q -x \"igp_france\" -s \"yesterday\" -e \"yesterday\" -m \"90000\" -w \"900\" -z partB >>\"/var/log/process/france-partB-console.log\" 2>&1\n\n"
  11. "00 12 * * 2-6 testuser JAVA_OPTS='-server -Xmx512m' /merge.sh \"yesterday\" \"igp_france\" \"partA,partB\" >>\"/var/log/process/france-console.log\" 2>&1\n"
  12. "00 08 * * 1-5 testuser /get_results.sh -q -x \"igpswitz_france\" -s \"today\" -e \"today\" -m \"15000\" -b >>'/var/log/process/igpswitz_france-console.log' 2>&1\n"
  13. "00 12 * * 2-6 testuser /get_results.sh -q -x \"igpswitz_france\" -s \"yesterday\" -e \"yesterday\" -m \"15000\" -Dapc.maxalerts=8000 -w \"900\" >>'/var/log/process/igpswitz_france-console.log' 2>&1\n\n"
  14. "30 07 * * 2-6 testuser /get_results.sh -q -x \"igp_franced\" -s 'yesterday' -e 'yesterday' -m \"105000\" -b >>\"/var/log/process/franced-console.log\" 2>&1\n"
  15. "15 12 * * 2-6 testuser /get_results.sh -q -x \"igp_franced\" -s 'yesterday' -e 'yesterday' -m \"105000\" -w \"960\" >>\"/var/log/process/franced-console.log\" 2>&1")
  16.  
  17. matches = re.finditer(regex, test_str)
  18. result = set()
  19.  
  20. for matchNum, match in enumerate(matches, start=1):
  21. result.add(match.group(2))
  22.  
  23. print(result)
Success #stdin #stdout 0.02s 9508KB
stdin
Standard input is empty
stdout
{'igp_france', 'igp_srm_m', 'igp_franced', 'igpswitz_france'}