From cb2b79be865f3e29fcb34f22f4a1acf2fdf5b9ed Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Mon, 3 Nov 2025 14:01:43 -0800 Subject: [PATCH] Helper for strings --- util/StringEx.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 util/StringEx.cs diff --git a/util/StringEx.cs b/util/StringEx.cs new file mode 100644 index 0000000..a92a03d --- /dev/null +++ b/util/StringEx.cs @@ -0,0 +1,29 @@ + + + + +public static class StringEx +{ + + + public static int LastIndexOfWithMax( this string str, char c, int maxChars ) + { + var strEnd = str.Length - 1; + + if( strEnd < 2 ) + return -1; + + for( int i = strEnd; i >= 0; i-- ) + { + if( str[i] == c ) + { + return i; + } + } + + return -1; + } + + + +} \ No newline at end of file