Teimpléad:MatchRegex
Cuma
Template to simplify code using Mòdul:String|match
and check whether a value match with a regular expressions pattern.
Usage
[athraigh foinse]{{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
[athraigh foinse]- 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