[Solved] Regex for this format [40]*100+ [closed]


This regexp tests for the format you describe:

/^(\[\d{1,3}\]\*\d{1,3}\+)+$/

\d{1,3} matches up to 3 digits. We put one of these inside literal [], with literal * after that, and literal + after the second one. Then we use a quantified group to allow multiple repetitions.

You can’t do the validation until the user has finished entering the field, because it won’t match the partial value while they’re typing. So you can use it in a change event listener, but not input or keydown.

2

solved Regex for this format [40]*100+ [closed]