Wilcard matching

Splash Forums Rewrite Users Wilcard matching

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 1 year, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27211

    j_l
    Participant

    Hi

    Is there any way of doing something like wildcard matching as the Tuckey filter does? I mean using *, **, and $

    Id like to do something like mapping they explain in their Tuckey doc:

    The wildcard matching engine can be used instead of regex. It is supported in conditions and rules where match-type is set to wildcard (or default-match-type is set on the urlrewrite element

    e.g. /big/url/* will match /big/url/abc.html but will NOT match /big/url/abc/dir/ or /big/url/abc/.

    /big/url/** will match /big/url/abc.html, /big/url/abc/dir/ and /big/url/abc/.

    You can also use Regular expression style variable replacement, each match of a * will be available for use in to and set elements using simple $1 $2 variables.

    e.g. /my/big/url/* will match /my/big/url/abc.html and $1 will be set to abc.html.

    Thanks very much

    • This topic was modified 1 year, 2 months ago by  j_l.
    #27213

    No, Rewrite is based on parameters which are represented by regular expressions. The default pattern for a parameter is [^/]*. But you can change that for each parameter. There is also a special parameter {*} that can be used if you are not interested in what is actually matched. Samples:

    // matches /big/url/foobar but NOT /big/url/foo/bar 
    .addRule(Join.path("/big/url/{param}").to("/something"))
    
    // same as above
    .addRule(Join.path("/big/url/{*}").to("/something"))
    
    // matches both /big/url/foobar AND /big/url/foo/bar
    .addRule(Join.path("/big/url/{param}").to("/something"))
    .where("param").matches(".*")
    
    #27214

    j_l
    Participant

    Thanks Christian

    What I can’t do is to store the partial match of a URL in variables like $1 and $2, am I correct?

    Cheers

    #27215

    You can use the same variable in the to() part like this:

    .addRule(Join.path("/big/url/{param}").to("/something/{param}.jsp"))
    
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.