Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Restrictions for player Username


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

Product Version: UE 4.20
more ▼

asked Sep 04 '18 at 07:04 AM in Blueprint Scripting

avatar image

36 2 2 6

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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. alt text

string.png (337.1 kB)
more ▼

answered Sep 04 '18 at 08:01 AM

avatar image

1.8k 12 7 8

avatar image Freymox Sep 04 '18 at 05:10 PM

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 alt text

alt text

avatar image Freymox Sep 04 '18 at 05:19 PM

Not Really working. See what it gives me back: alt text

avatar image Tuerer Sep 04 '18 at 05:28 PM

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:alt text

I skipped the length part intentionally not to overburden it, but it's the easiest part. alt text 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.

string2.png (74.3 kB)
string3.png (82.5 kB)
avatar image Freymox Sep 04 '18 at 05:43 PM

It works perfectly Thank you sooo much!!!

avatar image Tuerer Sep 04 '18 at 05:47 PM

Glad I could be of help!

avatar image Freymox Sep 04 '18 at 05:48 PM

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

avatar image Tuerer Sep 04 '18 at 05:50 PM

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

avatar image Freymox Sep 04 '18 at 05:54 PM

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

avatar image Tuerer Sep 04 '18 at 06:14 PM

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:alt text 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.

string.png (400.2 kB)
avatar image Freymox Sep 04 '18 at 06:41 PM

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? alt text

alt text

avatar image Tuerer Sep 04 '18 at 06:45 PM

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.

avatar image Freymox Sep 04 '18 at 06:51 PM

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

(comments are locked)
10|2000 characters needed characters left

You should look into string ops: https://api.unrealengine.com/INT/BlueprintAPI/Utilities/String/

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

alt text

capture.png (132.5 kB)
more ▼

answered Sep 04 '18 at 08:14 AM

avatar image

13.7k 74 25 57

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question