I need a .NET Regex that extracts the “field” and “width” values in the following string:
<element
attribute='{field}'
attribute='{field,}'
attribute='{ field }'
attribute='{ field, 0 }'
attribute='{field,0}'
attribute='{ field, 10 }'
attribute='{field,10}'
attribute='{ field, 100 }'
attribute='{field,100}'
/>
I need to capture everything between the { and } characters then extract the field and width. Width is everything between the , and } characters. If no , character then width is Null/Nothing.
Usage: Use
Regex.Matchesand extract the groups from eachEdit: You could add the static text in the expression too, but that would make it ‘harder’ to read IMO.