Advertisement
Guest User

Untitled

a guest
Sep 28th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. static String[] extractNumbers(String arg)
  2. {
  3. String[] temp = new String[arg.Length];
  4.  
  5. int j = 0;
  6. for (int i = 0; i < arg.Length; i++)
  7. {
  8. if (arg[i] >= '0' && arg[i] <= '9')
  9. {
  10. int begin = i, count = 0;
  11. while (arg[i] >= '0' && arg[i] <= '9')
  12. {
  13. count++;
  14. i++;
  15. }
  16.  
  17. if(count > 0)
  18. {
  19. temp[j] = arg.Substring(begin, count);
  20. j++;
  21. }
  22. }
  23. }
  24.  
  25. String[] result = new String[j];
  26. Array.Copy(temp, result, j);
  27.  
  28. return result;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement