How to Extract Special Characters from an Input

Hi,
I was wondering if it is possible to extract special characters from an input field.

If a user were to type something like “aB3?” into an input field, I would like to be able to see if the input contains any lowercase letters, uppercase letters, numbers or special characters.

For lowercase letters it is easy, I can extract the number by taking : “Input’s value:lowercase:number of characters”. And if the output number is greater than 0, I know that the input contains lowercase letters and for uppercase letters it is exactly the same but with using the “:uppercase” function.

For numbers, I haven’t found a way to extract the number of numbers but am currently using the function: “Input’s value:converted number” and if the output is not empty then I know that there is a number contained in the input (the actual amount of numbers is irrelevant to me, one number is enough).

However, I cannot find any way to see if there is a special character (e.g. ?, !, %) contained in the input. I can get the total number of character - the number of lowercase letters - the number of uppercase letters. And if that number is greater than 0, then there are more characters than just letters in the input, however this does not rule out the possibility of any numbers still being in the input. I cannot also subtract the number of numbers in the input from the total number of characters as I do not know the total number of numbers only if there are any at all. If I use the “:converted to a number” function it will subtract the numerical value of the number, not the quantity of digits/characters.

I was wondering if my solution would have something to do with Regex functions, but I have a very limited understanding of that and cannot see a clear way to sort my issue.

I hope this all made sense and wasn’t too wordy. I can see that I have typed “the number of numbers” repeatedly.
Thank you for any help or potential solutions that can be offered!

:uppercase and :lowercase don’t filter out numbers and non-alphanumeric characters.
What you want to use is :extract with regex and then :count the returned list of filtered characters.
You can play with the regular expression, for example \d to extract digits, [a-z] lowercase, [A-Z] uppercase, [^A-Za-z0-9] not alphanumeric. Of course the exact expression to use depends on the language used.

I’m so sorry, I’ve realised just now that the :uppercase and :lowercase functions don’t do what I thought they would and came back to edit this post. I don’t know why I thought it would and for some reason I didn’t test it but yes, you are right so now those conditions parts do not work either. :rofl:

I’m also still slightly confused about regex. The language would be English but how do use the expressions you mentioned in practise?

Okay, I’ve had a play with it and think I understand. Am I right in thinking that I simply paste the expressions that you provided into the Regex Pattern box and then take the :count?
It seems to work, I just thought that I’d check.

Many thanks for you help!!

1 Like

Regex is a way to extract text. It’s highly customizable, but a bit difficult to learn and very sensitive. However, Chat GPT does it for you quite well, so just write what you are try to extract, ask for RegEx output, and use that output in bubble to get the characters you want (test it of course).

Thank you, that’s good to know :rofl:

Yes, just like that.
Regular expressions are strange and difficult at the beginning, but they make sense and are fun after you play with them a bit. I often use https://regexr.com/ that explains the meaning of the expressions and has a great quick reference.

Thank you so much, this has been a great help!

1 Like