I am trying to read out scripts through C# and determine if they contain certain words, but these words should be identical to instead of only containing what I'm looking for. Is there a way to use the contains
-function, single out the word, and check if it is identical to the exact word?
How can I determine if it both contains and is identical to the search term?
Currently I am using the following script:
// GetScriptAssetsOfType<MonoBehaviour>() Returns all monobehaviour scripts as text
foreach (MonoScript m in GetScriptAssetsOfType<MonoBehaviour>())
{
if (m.text.Contains("Material"))
{
// Identical check?
}
}
How about a regex?
bool contains = Regex.IsMatch(m.text, @"\bMaterial\b");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With