JSFiddle - React, Tailwind, and code Playground

by rodrigonery

HTML

<select id="mySelect">
    <option value="SP-26">SP-26</option>
    <option value="26-SP">26-SP</option>
</select>

JavaScript

/* 
// jQuery 
$(function(){
    
    var $mySelect = $('#mySelect');
    
    $mySelect.on( 'change', function() {
        
       var value = $(this).find('option:selected').val();
       alert( /\d{2}/.exec( value )  );            
        
    });
    
});
*/

// JS puro 

;(function() {
    var selector = document.querySelector('#mySelect');
    selector.onchange = (function() {
        var value = this.options[0].value;
        alert( /\d{2}/.exec( value )  );  
    })        
}();