Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. const cutCMD = function(cmd, processName) {
  2. let c = cmd;
  3.  
  4. if (!c || c.length === 0) {
  5. return null;
  6. }
  7.  
  8. c = c.trim();
  9.  
  10. if (processName.indexOf(".exe")) {
  11. processName = processName.replace(/\.exe$/i, ""); // Remove .exe from processName
  12. }
  13.  
  14. // skip regex symbols
  15. processName = skipRegex(processName);
  16.  
  17. // Find what is have to be removed from cmd in a process tree
  18. let strToRemove = c.match(new RegExp(`^(.*?)${processName}([^\\s]+)?`, "i"));
  19.  
  20. // If has sth to remove
  21. if (strToRemove) {
  22. // Remove string from cmd
  23. c = c.replace(strToRemove[0].trim(), "");
  24. }
  25.  
  26. // Trim and return resulting cmd
  27. return c && c.trim();
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement