IfMatchActions


IfMatch options are used in any measure, of any type, to evaluate a Perl Compatible Regular Expression. The regular expression will be evaluated as "true" or "false" based on matching with the string value of the measure, and will execute IfMatchAction or IfNotMatchAction action options, which will contain one or more Bangs or commands.

There can be multiple sets of match and action options in the measure, by using IfMatch2 / IfMatchAction2 / IfNotMatchAction2 and so on.

The full range of PCRE regular expression functionality is supported, so the match can be made on all or part of the measure's string value, can test the order of sub-strings within the string, and can test for both the presence or absence of a sub-string within the string. Logical OR and AND testing can be done in the regular expression, using the | character to support OR and Lookahead assertions (?=..) to support AND.

Reserved characters in regular expression, which are .^$*+?()[{\| must be escaped with the \ character when used as a literal in the IfMatch option. If using a measure value as a section variable in the IfMatch option, the :EscapeRegExp modifier can be used to properly escape reserved characters in the measure.

Capture groups () should not be used in the regular expression, as nothing is being captured and no indexes are being created. The function is simply used to test if the string measure matches some regular expression pattern, and will either be "true" (IfMatchAction) or "false" (IfNotMatchAction).

Options

IfMatch, IfMatch2, ..., IfMatchN

The regular expression matched with the string value of the measure.

Examples: Measure value is "Red, Green, Blue"

IfMatch=Red, Green, Blue : true

IfMatch=.*Green.* : true

IfMatch=(?i).*green.* : true

IfMatch=^Red.* : true

IfMatch=.*Blue$ : true

IfMatch=Red|Blue : true

IfMatch=(?=Blue)(?=Red) : true

IfMatchAction, IfMatchAction2, ..., IfMatchActionN

Optional action to be executed when the regular expression in IfMatch results in "true". The action is executed only once when the condition becomes "true", so it needs to become "false" and again "true" to execute again.

IfNotMatchAction, IfNotMatchAction2, ..., IfNotMatchActionN

Optional action to be executed when the regular expression in IfMatch results in "false". The action is executed only once when the condition becomes "false", so it needs to become "true" and again "false" to execute again.

IfMatchMode Default: 0

If set to 1, the evaluation of the match will execute the appropriate actions in IfMatchAction or IfNotMatchAction on every update of the measure.

Note: Care should be taken not to create an infinite loop in the actions. In particular, !Refresh, !Update and !UpdateMeasure #CURRENTSECTION# should generally be avoided when IfMatchMode=1.

Example

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[MeasureDate]
Measure=Time
Format=%A, %B %#d, %Y
IfMatch=Saturday|Sunday
IfMatchAction=[!SetOption MeterDayofWeek Text "The date is [MeasureDate]#CRLF#It's a weekend"]
IfNotMatchAction=[!SetOption MeterDayofWeek Text "The date is [MeasureDate]#CRLF#It's a weekday"]
IfMatchMode=1
[MeterDayofWeek]
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1