+ 1
Use regular expression! It's very simple and useful once you understand well. Learn by self can make you perfect :) I can only guide you though! To fully understand, search regular expression on google ;)
Here's an example of usage about regular expression.
https://code.sololearn.com/cryyRL4bEs9v/?ref=app
PS. Sololearn's code playground only accept input one time, so inputs need to be separated by return.
In my example code, enter username then return, and type your password in newline!
I prefer using computer for running this code.
Happy coding!! :)