Closed ckennedy666 closed 2 years ago
Implemented in 0.10.0
Full javascript regular expression patterns (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
Since "?" matches a single character, your example would need to be coded as:
{{table item "F(?)" "[[Stellar Class#F|F]]$1" "G(?)" "[[Stellar Class#G|G]]$1"}}
where "(?)" is creating a numbered group containing a single character, and "$1" in the resulting string gets replaced by that first numbered group.
For a traveller UPP, you could use:
{{table upp "(\d)(\d)(\d)(\d)(\d)(\d)" "Str $1 Dex $2 End $3 Int $4 Edu $5 Soc $6"}}
which is a bit weird since there aren't multiple entries to extract, but it gets everything into a single string :-)
It would be useful if we could use wildcards such as "?" and "*" in the {{table ...}} helper. I could also see the need for a new helper to be defined.
Proposed behavior:
Given data of ["F1", "G3"]
template: {{table item "F?" "[[Stellar Class#F|F]]?" "G?" "[[Stellar Class#G|G]]?"}}
Produces: [[Stellar Class#F|F]]1 [[Stellar Class#G|G]]3
Thanks.