I'm working with asp.net C# and need a regex pattern to extract a portion of a pathname URI.
Example:
pathName1 = "/Tests/plans.aspx";
pathName2 = "http://mydomain.com/Tests/plans/error.aspx";
In both cases I need the pattern to extract "/Test/plans" from the given pathname. How would I do this?
Help! Need a regex pattern to parse a string from pathname URI
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

SivaRamaKrishna Raju43 reputationPosted Jan 11, 2011, 9:16 PM EST
Please clear about your requirement, because you given an example, this example is not clear
In both cases you need "/Test/plans", how it is possible
in the pathname1 contains path as /Test and plans.aspx is the file in that path
in pathname2 contains path as /Tests/plans and error.aspx is the file in that path
you need path means /Test in pathname1 and
/Tests/plans in pathname2,
First clear about your functionality then let us know your requirement.
Thanks and Regards,
SivaRamaKrishnaRaju..