Note that there are some explanatory texts on larger screens.

plurals
  1. POURL rewriting Regex with capture group
    primarykey
    data
    text
    <p>I'm writing the following regular expression using .NET's regex engine:</p> <pre><code>Regex reg = new Regex(@"/Explorer/PeopleDirectory([/\?].*)?$"); var a = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory/assets/images/logo.png", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); var b = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory/", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); var c = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); var d = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory.aspx", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); var e = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory?param1=value1&amp;param2=value2", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); var f = reg.Replace(@"http://localhost:106/Explorer/PeopleDirectory/?param1=value1&amp;param2=value2", "/Explorer/PeopleDirectoryProxy.aspx?pdurl=$0"); </code></pre> <p>My desired output would be: </p> <pre><code>http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=assets/images/logo.png http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl= http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl= No match (as-is) http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=?param1=value1&amp;param2=value2 http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=?param1=value1&amp;param2=value2 </code></pre> <p>Current output is:</p> <pre><code>http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=/Explorer/PeopleDirectory/assets/images/logo.png http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=/Explorer/PeopleDirectory http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=/Explorer/PeopleDirectory No match (as-is) http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=/Explorer/PeopleDirectory?param1=value1&amp;param2=value2 http://localhost:106/Explorer/PeopleDirectoryProxy.aspx?pdurl=/Explorer/PeopleDirectory/?param1=value1&amp;param2=value2 </code></pre> <p>Assume URL encoding of result later. How do I get rid of the /Explorer/PeopleDirectory/ from appearing in the output? </p> <p>I thought I was only capturing the part that comes after the /Explorer/PeopleDirectory.... part so that when I reference it using $0 it would only capture the part in the parentheses? Could someone please explain where I've erred?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload