I have tried the https://www.regex101.com/#javascript tool, as well as a similar stackoverflow question and yet haven't been able to solve/understand this. Hopefully someone here can explain what I am doing wrong. I have created as detailed, step-by-step of an example as I can.
My goal is to be able to parse custom attributes, so for example:
I wrote some jquery code to pull in the attribute and the value, and then wanted to run regex against the result.
Below is the html/js, the output screenshot, and the regular expression screenshot, which says my regex query should match what I am expecting.
Expected result: 'valOne' Result: ':valOne' <-- why am I getting a ':' character?
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script>
      $(document).ready(function() {
        $('[customAttr]').each(function(){
          var attrValues = $(this).attr('customAttr');
          var regEx_attrVal = /[\w:]+?(?=;|$)/g;
          var regEx_preColon = /[\w]+?(?=:)/g;
          var regEx_postColon = /:(\w*)+?(?=;|\b)/g;
          var customAttrVal = attrValues.match(regEx_attrVal);
          var customAttrVal_string = customAttrVal.toString();
          console.log('customAttrVal:');
          console.log(customAttrVal);
          console.log('customAttrVal_string: '+customAttrVal_string);
          var preColon = customAttrVal_string.match(regEx_preColon);
          preColon_string =preColon.toString();
          console.log('preColon');
          console.log(preColon);
          console.log('preColon_string: '+preColon_string);
          var postColon = customAttrVal_string.match(regEx_postColon);
          postColon_string = postColon.toString();
          console.log('postColon');
          console.log(postColon);
          console.log('postColon_string: '+postColon_string);
          console.log('pre: '+preColon_string);
          console.log('post: '+postColon_string);
        });
      });
    </script>
  </head>
  <body>
      <div customAttr="val1:valOne">
        Test custom attr
      </div>
  </body>
</html>


 
     
     
     
     
    