string_util library

Helper functions to performantly transform strings, without RegExp.

Functions

stripRegexStraySlashes(String str) → String
Removes the leading and trailing escaped slashes (\/) of str.
stripStray(String haystack, String needle) → String
Removes every leading and trailing occurrence of needle from haystack, as haystack.replaceAll(RegExp('^($needle)+|($needle)+\$'), '') does with needle escaped, but without a RegExp.
stripStraySlashes(String str) → String
Removes the leading and trailing slashes of str, as str.replaceAll(RegExp(r'(^/+)|(/+$)'), '') does, but about 40 times faster. Only slashes gives ''.