Please tell me how to write the required conditions for entering numbers and kanji in regular expressions.

Asked 1 years ago, Updated 1 years ago, 258 views


To prevent missing numbers in the street number when users enter addresses Please tell me how to write the required conditions for entering numbers and kanji in regular expressions.

I tried using the code below, but I am troubled because I can enter only kanji.

^[0-91- ]]*$

regular-expression

2023-02-12 13:39

1 Answers

^[0-91- ]]*$

Let's keep in mind whether 1- < is acceptable for Kanji.(It doesn't make sense after all)

If the numbers and kanji must appear at least once, for example,

[1- ]].*[0-9]

I see.

Now, the main topic is

Prevent missing numbers when entering addresses

I think so, but it doesn't make much sense to check the regular expression because it's either a monkey or a monkey.

For example, if the above numbers are written in so-called full-width letters, they will not match.If full-width numbers are included in the name of the place itself, it will pass through the check and will not prevent omission of input.
Furthermore, there are some addresses in the world that don't have a street number.

If it's a problem to miss input, it's better to devise the UI than checking the character type, but this is a lot of trouble.If you divide the street number field, you can cause a omission by dividing it.

Considering usability, entering an address is actually a very difficult task, so you should think about it properly.


2023-02-12 13:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.