Hitachi

JP1 Version 12 JP1/IT Desktop Management 2 - Asset Console Creating an Access Definition File Guide


$MATCH (check string)

$MATCH evaluates the characters used in a character string, and returns the number of characters up to but not including the first character that does not match.

Organization of this page

Syntax

return-value=$MATCH(character-string,evaluation-format)

Values

Status

The following table lists and describes the possible statuses:

Status

Description

NORMAL

Normal end

NODATA

No character that matches evaluation-format was found.

ERROR

Script execution interrupted

An invalid argument was specified, or an error other than the above occurred.

Legend:

—: Not applicable

Example

Example 1

The following example checks for characters other than alphanumeric characters:

[SET_VALUE]
  DATA = 'user$1'
  VAL  = $MATCH(DATA,'[^a-zA-Z0-9]')
[IF]
  VAL = ''
  [THEN]
    [SET_VALUE]
      MSG  = 'MATCH OK'
      $ECHO(MSG)
  [ELSE]
    [SET_VALUE]
      MSG  = 'MATCH NG ('+VAL+')'
      $ECHO(MSG)
[IF_END]
Execution result:

MATCH NG (4)

Example 2

The following example checks date formats:

[SET_VALUE]
  DATA = '2015/04/01'
  VAL  = $MATCH(DATA,'^[1-2][0-9][0-9][0-9]/[0-1][0-9]/[0-3][0-9]$')
[IF]
  VAL != ''
  [THEN]
    [SET_VALUE]
      MSG  = 'MATCH OK'
      $ECHO(MSG)
  [ELSE]
    [SET_VALUE]
      MSG  = 'MATCH NG'
      $ECHO(MSG)
[IF_END]
Execution result:

MATCH OK