Search code examples
regexvb.netlookbehindquantifiers

What is the RegEx for this match?


I am trying to match the number before the semicolon but I can't use a quantifier in my lookbehind so I have no idea how to make this work.

The string (yes, there are tab spaces in between "item[##]" and "=")

<script language="javascript">
item[19]    = 13;
item[14]    = 13;
item[17]    = 7;
item[1] = 2;
</script>

I'd like to get the 13, 13, 7, and 2

This is my current RegEx, which obviously does not work:

(?<=item\[[0-9]).*?(?=;)

Solution

  • Get it at matched group 1 that is captured by using parenthesis ()

    String literals for use in programs:

    @"item\[\d+\].*?=\s+(\d+);"
    

    Tested it here