How can I know if a string of letters contains numbers? For example a password: Mariana03 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I know if a string of letters contains numbers? For example a password: Mariana03

I have found isdigit()but this only says if it is completely of numbers or letters

19th Aug 2018, 4:34 PM
Mariana
5 Answers
+ 3
You could create one function by yourself. Create an array with digits from 0 to 9 and then check wether any character matches the elements of the array with digits... The rest is to choose the programming language😂
19th Aug 2018, 4:47 PM
Ledio Deda
Ledio Deda - avatar
+ 2
Maybe you should change the type of input box from password to text...I am not sure if I got it right...
19th Aug 2018, 4:55 PM
Ledio Deda
Ledio Deda - avatar
+ 1
Can you use regex? If yes, what language? Note, if you've never seen regex before, it may seem weirder than more straightforward solutions (up to you if that matters). edit: You could use isdigit() on one character at a time, breaking out of your loop (fail condition) if it returns true.
19th Aug 2018, 5:33 PM
Kirk Schafer
Kirk Schafer - avatar
0
yes but if the password is an input? I don't know what length off the password
19th Aug 2018, 4:54 PM
Mariana
0
You can creat a function that will define the length of the function and returns it
28th Aug 2018, 10:00 PM
Panmo Yves Larousse
Panmo Yves Larousse  - avatar