Advertisement
RedKnight91

string_fill

Sep 28th, 2019
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///@func    string_fill(string, template, str1, str2, ...
  2. ///@desc    Replaces template substrings (e.g. "%%"), with given strings, thus 'completing' the string
  3. ///         Example:    greeting = "%%, my name is %%!";
  4. ///                     greeting = string_fill(greeting, "%%", "Hi", "Mike");
  5. ///
  6. ///         Result:     "Hi, my name is Mike"
  7. ///
  8. ///@param string
  9. ///@param template
  10. ///@param str1
  11. ///@param str2
  12. ///@param ...
  13.  
  14. var _string = argument[0];
  15. var _template = argument[1];
  16.  
  17. for (var _i = 2; _i < argument_count; _i++)
  18.     _string = string_replace(_string, _template, string(argument[_i]));
  19.    
  20. return _string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement