Reading the name of scripts, and creating an array?

Is is possible to get a script based on a part of its name? Where one script is told to get components with “Magic” in their name (There would be more than one, so it would also have to accept Magic1, Magic2.) And then create an array of them so they can all be referenced together?

The only way I could thing of would be to try using a regex I’ve never actually tried using regular expression inside unity so I’m not entirely sure how GetComponent() would handle that.

From what I can see you would need to first somehow get an array of all the strings to apply the regex to. I think it would be faster to do something like get a list of possible components you would want.

public string[] components = new string[upperValue];

Then you could just iterate through that array for the GetComponent(). I feel like that would be the easiest way really. Could always also look at using a Generic List (from System::Collections::Generics) if you wanted to dynamically resize it. I would be interested to see what kinda luck you might have with regexe’s or character classes in unity. I haven’t done a lot of “text processing” inside unity as of yet.