Restrictions for player Username

Hello.

I’m making player creation widget, where players need to enter they own custom username.
Now try to figure out few restrictions, and no idea how to make them.

  1. First letter should be capital, rest of them small.
  2. First letter should be a letter not a number.
  3. Min amount 5 max 12.
  4. No special symbols.
  5. Maybe even not allow to user numbers too. That’s what I haven’t decided yet.
    Was trying different ways how to restrict that for text box, but no success so far. And can’t find any tutorial eater.

Thank you

After some research I see that there are no such instruments in the blueprints (text masks or regular expressions like they have it in C++). So I believe you’ll have to do it manually.


Furthermore, I didn’t find a way to check the character case. You can convert it ToUpper() or ToLower(), but you can’t check what it is. So after some thoughts I had the following idea:

  1. Create a string “abcdefghijklmnopqrstuvwxyz0123456789” and check if all the characters in the player’s name are contained in there. If not, print out an error, e.g. “No Special Symbols or Spaces Allowed” or something.

  2. Create a string “ABCDEFGHIJKLMNOPQRSTUVWXYZ” and check the first character against it, case sensitive.

  3. Check all the other characters against the first string, case sensitive.



    Here’s what I made. Sorry for the mess, I tried to fit everything into one screen. Hope you can figure it out.

You should look into string ops:

This, for example, will Capitalise the string and will not allow the first entry to be a number:

I see the error there, my bad. I believe I was rearranging nodes and missed the index for the second For Loop. It should be like this:




I skipped the length part intentionally not to overburden it, but it’s the easiest part.

Just hook it up at the beginning.


And you don’t have to use Make Literal String nodes, it’s just to create a string directly in the blueprint without creating String variables. You can connect everything directly to that tiny Text 2 String node.

It’s awesome. I think it works perfect, but to be sure for 100% need to add somehow Username length as well. because it gives me back that text is correct and Error: All Other Charachters Must Be Lower Case

Not Really working. See what it gives me back:

It works perfectly Thank you sooo much!!!

Glad I could be of help!

Ah no. In some situations it still put’s me trough even if nick name is incorrect.

Bummer. Something must be wrong then. Give me a few minutes to review.

No worry.

  1. If I put symbol as first, it never puts me trough, so it’s good.
  2. If I put all small letters it shows me an error about upercase, but still go trough, like it would be correct.
  3. If I put Capital first and then few small and then symbols, it gives me an error and still let trough
  4. If I put correct text, it goes trough, but still gives me an error that rest of letters should be low

Ah, this. Yes, that’s how the Loop behaves, it checks each character in the name and returns Text Correct multiple times. A way around may be, for example, setting a Bool variable that will be set to True if there’s any kind of error at all. Something like this:

I removed Substrings and used Everynone’s advice about Left, and just changed the indices for the second For Loop not to use Substring at all, and replaced alphabets with variables because they take less room in the blueprint that way.


The main idea is not to use branches after the loops to determine whether the player’s name is correct, but to check it only once at the very end of the function.

Yes, you have to reset the bool, you’re right.

I don’t know about the double No Error. If you only connect it to the second For Loop’s Completed output it should be printed out only once.

Thank you. Now it works perfectly only one more question.
So if I enter name correctly at first try, it returns me only one Print with text “No Errors Found”. But if I make a mistake at first try, like put symbol. It gives me an error and now need to correct mistake. So bul needs to be reset. I did like these, but only question is, after I correct my username how it should be, why it returns “No Errors Found” Twice?

Ok! Thank you so much for your help! That was big one :smiley: Hopefully it’s gonna help to others too. Because as I said, there is not really an info about my problem.