I want to define a variable in my regular expression in a way that I can simply extract its corresponding value from matched input string.
For example, I have a pattern like this: "\w*\s+\d+",
And an input string like: "aaa 113"
When the matching string is received, I want to be able to simply extract the value corresponds to the part of pattern which says "\d+" which is numerical value using C#
Need to mention that I am storing expressions in a database table and I want to extract variables from matched strings and pass their values to a dynamically retrieved query or stored procedure.
I want to the procedure to be completely context-free as we don’t the occurrence place of variables and their values in matching string.
You can use match groups with names without depending on its order in the pattern: