File

projects/wms-framework/src/lib/baseframework/Regex/Match.ts

Description

Class representing the Match object.

Index

Properties
Methods

Constructor

constructor(expression: string, target: string, option: RegexOptions)

Init an instance of Match.

Parameters :
Name Type Optional Description
expression string No

The regular expression.

target string No

The target string to be evaluated.

option RegexOptions No

The option.

Properties

Private expression
Type : string
Private option
Type : RegexOptions
Private target
Type : string

Methods

Public success
success()

Return if the current match is succeded.

Returns : boolean

True if the match is succeded.

import { RegexOptions } from './RegexOptions';

/**
 * Class representing the Match object.
 */
export class Match {
  private expression: string;
  private target: string;
  private option: RegexOptions;

  /**
   * Init an instance of Match.
   * @param expression The regular expression.
   * @param target The target string to be evaluated.
   * @param option The option.
   */
  constructor(
    expression: string,
    target: string,
    option: RegexOptions = RegexOptions.None
  ) {
    this.expression = expression;
    this.target = target;
    this.option = option;
  }

  /**
   * Return if the current match is succeded.
   * @returns True if the match is succeded.
   */
  public success(): boolean {
    let flags = RegexOptions.toString(this.option);
    if (flags != null) {
      return new RegExp(this.expression, flags).test(this.target);
    }

    return new RegExp(this.expression).test(this.target);
  }
}

result-matching ""

    No results matching ""