I have a question for the regular show!

Asked 1 years ago, Updated 1 years ago, 62 views

In the part where you enter the date, in EditText, Which regular expression allows you to enter only numbers from 1-31?ㅠ<

regex android date sign-up

2022-09-22 14:05

4 Answers

You can get a lot of information by searching for "androidedittext number range". In conclusion, you can use InputFilter to allow only the desired range of numbers to be entered.

https://stackoverflow.com/questions/14212518/is-there-a-way-to-define-a-min-and-max-value-for-edittext-in-android


2022-09-22 14:05

You can test regular expressions in real time on sites like regex101.

I also recommend the book Regular expressions that you can hold in your hands . It's a regular expression that I learn in 10 minutes, and the book is thin and easy to understand.

I don't know the Java regular expression, but I know it's basic in JavaScript, but if it's a JavaScript regular expression, you can do it like this.

Combining these three into (a | b | c)

([0-9]|[1-2][0-9]|3[0-1]) I think so.


2022-09-22 14:05

Do you have to verify this as a regular expression? When the input value is an integer, you can check if it is greater than 0 and less than 32.


2022-09-22 14:05

There are three conditions. 1 to 9 days 10th to 29th 30th and 31st You can check it as below.

(0?[1-9]|[12][0-9]|3[01])


2022-09-22 14:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.