Question: I've tried several answers on stackoverflow and non are working for me. I basically need all traffic on my site to end up at <https://www.domainname.com>. I can get everything working with the rules below except if someone types in <https://domainname.com>. In this case I need to add www to it.

```
 <match url="(.*)" />
 <conditions>
 <add input="{HTTP}" pattern="^domainname.com$" ignoreCase="true" />
 </conditions>
 <action type="Redirect" url="http://www.domainname.com/{R:1}" redirectType="Permanent" appendQueryString="true" />
 </rule>
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
 <match url="(.*)" />
 <conditions>
 <add input="{HTTPS}" pattern="^OFF$" ignoreCase="true" />
 </conditions>
 <action type="Redirect" url="https://www.domainname.com/{R:1}" redirectType="Permanent" />
 </rule>```

```

Answer: 
Thanks to Eric I realized that regular expressions can be used in snakemake rules' wildcards. The only problem is then that snakemake does not accept "empty" wildcards, but this can be overridden as explained in the post here: <https://groups.google.com/g/snakemake/c/S7fTL4jAYIM?pli=1>
Thus the solution to my problem is as follows:

```
rule both:
    input:
        vals_pca    = 'stats/input_{type}{amount}.npz',
    output:
        for_cnv     = 'stats/output_{type, tt|gs}{amount, .{0}|_d.+}.npz'
    run:
        # DO STUFF

```

Snakemake will match `{amount, .{0}|_d.+}` as an empty string or string beginning with `_d`.
Hope it will help somebody.
Can't you do it the very simple way:

```
rule with_something:
    input:
        vals_pca    = 'stats/input_{something}.npz',
    output:
        for_cnv     = 'stats/output_{something}.npz'
    run:
        # DO STUFF

```

Wildcards are defined by the output files. If you ask for file `output_typeWhatever_dWhatever.npz` then the rule will look for `input_typeWhatever_dWhatever.npz`. If you ask for file `output_typeWhatever.npz` then the rule will use as input `input_typeWhatever.npz`.

Keep you rules as simple/generic as possible. Don't forget that snakemake resolves the wildcards from the final file you ask for and goes down the rules to see how to produce this file.