Advertisement
plonp

GML string_remove_badspaces

Jan 6th, 2023 (edited)
1,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Remove extra spacing from string (argument)
  2.  
  3. function string_remove_badspaces(str) {
  4.     var badSpaceFront = string_char_at(str,1);;
  5.     while badSpaceFront == " " {
  6.         str = string_delete(str, 1, 1);
  7.         badSpaceFront = string_char_at(str,1);
  8.     }
  9.     var badSpaceBack = string_char_at(str,string_length(str));;
  10.     while badSpaceBack == " " {
  11.         str = string_delete(str, string_length(str), 1);
  12.         badSpaceBack = string_char_at(str,string_length(str));
  13.     }
  14.     var badSpaceRemainsPos = string_pos("  ", str);;
  15.     while badSpaceRemainsPos != 0 {
  16.         str = string_delete(str, badSpaceRemainsPos, 1);
  17.         badSpaceRemainsPos = string_pos("  ", str);
  18.     }
  19.     return str;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement