<matchesPattern>
<matchesPattern>
is an Evaluation
component that returns the boolean value of true
or false
depending on whether the enclosed
math (often a referenced <mathInput/>
) conforms to the specified pattern
template.
Attributes and Properties
Attribute | Type | Values |
---|---|---|
allowedErrorInNumbers = "…" | number | |
allowedErrorIsAbsolute = "…" | boolean | "true" "false" |
allowImplicitIdentities = "…" | boolean | "true" "false" |
allowPermutations = "…" | boolean | "true" "false" |
caseInsensitiveMatch = "…" | boolean | "true" "false" |
excludeMatches = "…" | mathList | |
expandOnCompare = "…" | boolean | "true" "false" |
includeErrorInNumberExponents = "…" | boolean | "true" "false" |
matchBlanks = "…" | boolean | "true" "false" |
matchByExactPositions = "…" | boolean | "true" "false" |
matchExpressionWithBlanks = "…" | boolean | "true" "false" |
numPeriodicSetMatchesRequired = "…" | integer | |
numSignErrorsMatched = "…" | number | |
pattern = "…" | ||
requireNumericMatches = "…" | boolean | "true" "false" |
requireVariableMatches = "…" | boolean | "true" "false" |
simplifyOnCompare = "…" | text | "none" "full" "numbers" "numberspreserveorder" |
symbolicEquality = "…" | boolean | "true" "false" |
unorderedCompare = "…" | boolean | "true" "false" |
Property | Type |
---|---|
$m.allowedErrorInNumbers | number |
$m.allowedErrorIsAbsolute | boolean |
$m.allowImplicitIdentities | boolean |
$m.allowPermutations | boolean |
$m.caseInsensitiveMatch | boolean |
$m.disabled | boolean |
$m.excludeMatches | mathList |
$m.expandOnCompare | boolean |
$m.fixed | boolean |
$m.fixLocation | boolean |
$m.hidden | boolean |
$m.includeErrorInNumberExponents | boolean |
$m.matchBlanks | boolean |
$m.matchByExactPositions | boolean |
$m.matchExpressionWithBlanks | boolean |
$m.numMatches | number |
$m.numPeriodicSetMatchesRequired | integer |
$m.numSignErrorsMatched | number |
$m.patternMatches | [ math ] |
$m.requireNumericMatches | boolean |
$m.requireVariableMatches | boolean |
$m.simplifyOnCompare | text |
$m.symbolicEquality | boolean |
$m.text | text |
$m.unorderedCompare | boolean |
$m.value | boolean |
Example: Default case
The <matchesPattern>
component is used to check that the user has supplied an
equation in the requested format. The pattern
attribute is required. If used without
additional attributes as shown above, a rather liberal comparison occurs.
- there must be two operands on one side, and none on the other
- one side must contain only (RHS or LHS are acceptable)
- the operands may be
+
or-
These requirements may be tightened, if desired, by applying additional
attributes to <matchesPattern>
.
Example: Match a specific form of linear equation
In this example, the following conditions must be met:
- a by itself on one side, and an on the other, and no other variables can be present
- the value must have a numerical coefficient, or no coefficient
- switching the order of terms on the right-hand side is acceptable
The attribute requireNumericMatches
ensures that the user only enters numerical coefficients
into the ( )
spaces (rather than an x
, for example.). Multiple <award>
conditions are used to
ensure that the case where does not have a coefficient are allowed.