Jump to content

Teimpléad:MatchRegex/doc

Ón Vicipéid, an chiclipéid shaor.

Template to simplify code using Mòdul:String|match and check whether a value match with a regular expressions pattern.

  • {{MatchRegex|<value>|<pattern>|<action if match>|<action when unmatch>}}
  • All parameters are positionals.
  • Paràmetres 3 & 4 are optionals. Without them, returns y or n, 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


See also

[athraigh foinse]