toRegExpValue static method

RegExp? toRegExpValue(
  1. CliOptDef optDef,
  2. String value, {
  3. dynamic param,
})

Converter: to RegExp value

Implementation

static RegExp? toRegExpValue(CliOptDef optDef, String value,
    {dynamic param}) {
  if (param == null) {
    return RegExp(value);
  }

  if (param is RegExpOpt) {
    return RegExp(
      value,
      caseSensitive: param.caseSensitive,
      dotAll: param.dotAll,
      multiLine: param.multiLine,
      unicode: param.unicode,
    );
  }

  if (param is String) {
    var rxo = RegExpOpt.fromString(param);

    return RegExp(
      value,
      caseSensitive: rxo.caseSensitive,
      dotAll: rxo.dotAll,
      multiLine: rxo.multiLine,
      unicode: rxo.unicode,
    );
  }

  return null;
}