in reply to Looking for a Regex

I, too, believe that what you want is a regex. I also agree with 1nickt that this isn't a code writing service. Assuming from your uncertainty that you are unfamiliar with regexes - a terrifyingly complex subject - let me try to get you started.

Character classes seem to be what you want. There are lots of resources on line, for example https://www.regular-expressions.info/charclass.html. You may or may not need different classes for each of your parts. A class for letters, digits and the other three you mention might be:

[a..z0..9'-_]

Using i after the final slash will make the regex case insensitive, meaning that you don't need to include upper case letters as well.

If you are familiar with testing, I recommend writing this as a series of tests to build up the regex one requirement at a time. Your test file will then explain to you in six months' time what you were trying to do. You won't remember otherwise. If you aren't, testing is a very useful tool to learn.

Regards,

John Davies