Skip to content

Instantly share code, notes, and snippets.

@gilzoide
Created March 15, 2025 01:12
Show Gist options
  • Save gilzoide/f6ef62c2a46af140d017af0fc280f91a to your computer and use it in GitHub Desktop.
Save gilzoide/f6ef62c2a46af140d017af0fc280f91a to your computer and use it in GitHub Desktop.
Common prefix for 2 strings in GDScript
## Get common prefix for 2 strings
static func get_common_string_prefix(s1: String, s2: String) -> String:
var common_length = min(s1.length(), s2.length())
for i in range(common_length):
if s1[i] != s2[i]:
return s1.substr(0, i)
return s1.substr(0, common_length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment