Advertisement
Guest User

Untitled

a guest
May 27th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string url = "www.google.com?cd=*|MMERGE25|*&mail=*|EMAIL|*&first=*|FNAME|*&last=*|LNAME|*&company=*|MMERGE4|*&cif=*|MMERGE58|*";
  2. string urlNeeded = url.replace("www.google.com?", ""); //Es un replace, pero simplement li estic dient que ho remplaçi per res, aixi que es mes un "borrar"
  3. //urlNeeded = cd=*|MMERGE25|*&mail=*|EMAIL|*&first=*|FNAME|*&last=*|LNAME|*&company=*|MMERGE4|*&cif=*|MMERGE58|*;
  4. string cleaned = url.replace('&', '=');
  5. //urlNeeded = cd=*|MMERGE25|*=mail=*|EMAIL|*=first=*|FNAME|*=last=*|LNAME|*=company=*|MMERGE4|*=cif=*|MMERGE58|*;
  6. string[] splitted = url.split('=');
  7. //splitted = [cd,*|MMERGE25|*,mail,*|EMAIL|*,first,*|FNAME|*,last,*|LNAME|*,company,*|MMERGE4|*,cif,*|MMERGE58|*];
  8. //splitted[0] = "cd";
  9. //splitted[1] = "*|MMERGE25|*";
  10. //splitted[2] = "mail";
  11. //splitted[3] = "*|EMAIL|*";
  12. //etc.
  13. int companyKeyIndex = splitted.indexOf("company");
  14. //companyKeyIndex = 8;
  15. int companyValueIndex = companyKeyIndex + 1;
  16. //companyKeyIndex = 9;
  17. string companyValue = splitted[companyValueIndex]
  18. //companyValue = "*|MMERGE4|*"
  19. string companyValueCleaned = companyValue.replace('*', ''); //El mateix que previament, es un replace pero enten-ho com borrar
  20. //companyValueCleaned = "|MMERGE4|";
  21. //si volguesis treure les barres tambe s'afegiria aquesta linia (sense crear una nova variable, utilitzant ja la que tens)
  22. companyValueCleaned = companyValue.replace('|', '');
  23. //companyValueCleaned = "MMERGE4";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement