.net - Trouble with regex capturing group & lazy match -
using .net c#, want match names in $select clause in follownig :
http://serveraddress/odataserv/wcfdataservice.svc/persons?$select=last_name_idnt,first_name_idnt&$top=1&$filter=id eq '0000'
so have "last_name_idnt,first_name_idnt" (i'll split later based on comma)
the $select clause can in middle of url, or @ end, i.e :
http://serveraddress/odataserv/wcfdataservice.svc/persons?$top=1&$filter=id eq '0000'&$select=last_name_idnt,first_name_idnt
so wrote following pattern : (\$select\=)(.[^&])*(&|$)
, tried group 2. don't know if it's because of lazy matching, group 2 contains 2 characters : "nt" in example.
i don't know how make can retrieve "last_name_idnt,first_name_idnt"
thanks in advance
the regex using :
(\$select\=)(.[^&])*?(&|$)
(.[^&]) - capturing group captures 2 characters together. character , not &.
now (.[^&])*? means 0 or more set of these 2 characters lazy match. capturing group have last 2 characters of match
use instead:
(\$select\=)([^&]*)
Comments
Post a Comment