fork download
  1. // your code goes here
  2. //let regex = /(\w+(,|\s)*)+;/;
  3. let regex = /(\w+(,|\s)+)+(\w+);/;
  4. let text = "XXXX,XXXX,XXX,XXX,XXXX,XXX,XXXX,XXX,XXX,XXX,XXXX, XXXXX";
  5.  
  6. let matched = text.match(regex);
  7. if (matched != null) {
  8. print(matched[0]);
  9. } else {
  10. print(null);
  11. }
  12.  
  13. text = "XXXX,XXXX,XXX,XXX,XXXX,XXX,XXXX,XXX,XXX,XXX,XXXX, XXXXX;";
  14. matched = text.match(regex);
  15. if (matched != null) {
  16. print(matched[0]);
  17. } else {
  18. print(null);
  19. }
  20.  
Success #stdin #stdout 0.02s 16800KB
stdin
Standard input is empty
stdout
null
XXXX,XXXX,XXX,XXX,XXXX,XXX,XXXX,XXX,XXX,XXX,XXXX, XXXXX;