regextuckey-urlrewrite-filter

How to only include normal strings of text but not anything that contains a " .* "


How would i get only strings out of a piece of text and not the piece of text if it contains a .*

so for example:

foo would return foo

foo.test would return nothing

foo.blah would also return nothing.

This is what I've got right now

<from>/(.*(?<!.css|.js|.jsp|.gif|.jpg|.png))$</from>

But All i need it instead of adding in all .something etc one that will do all if it contains a .

This is what it is used for:

A url rewriting api http://tuckey.org/urlrewrite/ and it in in a .xml file if that is of any help?

this is my entire xml

<!DOCTYPE urlrewrite
        PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>

    <!--vote.jsp-->
    <rule>
        <from>/vote/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))$</from>
        <to>/vote.jsp?id=$1</to>
    </rule>
    <!--server.jsp-->
    <rule>
        <from>/server/([0-9]+)</from>
        <to>/server.jsp?id=$1</to>
    </rule>

    <!--index.jsp-->
    <rule>
        <from>/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))$</from>
        <to>/?game=$1&amp;sort=$2&amp;page=$3</to>
    </rule>
    <rule>
        <from>/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))/(.*(?&lt;!.css|.js|.jsp|.gif|.jpg|.png))$</from>
        <to>/?game=$1&amp;sort=$2</to>
    </rule>

</urlrewrite>

Solution

  • Instead of matching .* (zero or more of anything), match [^.]* (zero-or-more of anything except a period).

    Thus:

    <rule>
        <from>/vote/([^.]*)$</from>
        <to>/vote.jsp?id=$1</to>
    </rule>