Template:MatchRegex
Jump to navigation
Jump to search
Template to simplify code using Mòdul:String|match
and check whether a value match with a regular expressions pattern.
Usage
[edit]{{MatchRegex|<value>|<pattern>|<action if match>|<action when unmatch>}}
- All parameters are positionals.
- Paràmetres 3 & 4 are optionals. Without them, returns
y
orn
, when match/unmatch value with pattern.
Examples
[edit]- match without action:.........
{{MatchRegex|Q55555|[PQ]%d+}}
returns >> y - NO match without action:..
{{MatchRegex|Q55555a|[PQ]%d+}}
returns >> n - match with action:...........
{{MatchRegex|02-11-2019|%d%d%-%d%d%-%d%d%d%d|equal|different}}
returns >>equal
- NO match with action:....
{{MatchRegex|2-11-2019|%d%d%-%d%d%-%d%d%d%d|correct|wrong date}}
returns >>wrong date
See also
[edit]The above documentation is transcluded from Template:MatchRegex/doc (edit | history). Editors can experiment in this template's sandbox (create | mirror) and testcases (create) page. Please add categories to the /doc subpage. Subpages of this template. |