'How to allow two input values using an HTML pattern attribute

I'm looking to constrain user input using an HTML pattern attribute on a text input, I didn't want to use a select or radio buttons tag for design purposes. I tried many approaches but none of them allowed me to get to what I want.

<form action="" method="post">

<input type="text" class="study" name="study" placeholder="Enter your year of study L1-3,M1-2 "  pattern="[L-l-M-m]+[1-2-3]" maxlength="2" title="only L1,L2,L3 and M1,M2 are allowed" required>
<button name="submit" class="btn" type="submit">Register</button>

</form>


Solution 1:[1]

found the answer [L]{1}[1-3]|[M]{1}[1-2] using https://regex101.com and using logical or enter image description here

Solution 2:[2]

Use this pattern: [LM]{1}[0-9]{1}

You can check if this work for you with this tool: https://regex101.com

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ELMEHDAOUI Ahmed
Solution 2 Vito V