activities
latest
false
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。
UiPath logo, featuring letters U and I in white

ワークフローのアクティビティ

最終更新日時 2026年3月13日

VerifyIsRegexMatch

最初の式が 2 番目の式の正規表現の一致するかどうかを検証します。

定義

名前空間: UiPath.Testing.API

アセンブリ: UiPath.Testing.Activities.API (UiPath UiPath.Testing.Activities.Api.dll)

VerifyIsRegexMatch(object, object, string)

bool VerifyIsRegexMatch(
   object firstExpression
   object secondExpression
   string outputMessageFormat = null
)
bool VerifyIsRegexMatch(
   object firstExpression
   object secondExpression
   string outputMessageFormat = null
)

firstExpression オブジェクト : 検証プロセスの最初の式です。これは、正規表現と一致するかどうかを確認するための、文字列またはその他のオブジェクトです。

secondExpression オブジェクト : 検証プロセスの 2 番目の式です。これは、 firstExpression が一致する必要がある正規表現です。

outputMessageFormat String : 出力メッセージの形式です。次の引数がサポートされています。

  • {LeftExpression}
  • {LeftExpressionText}
  • {RightExpression}
  • {RightExpressionText}
  • {Result}

詳しくは、「outputMessageFormatを設定する」をご覧ください。

戻り値

最初の式が 2 番目の式の正規表現の一致の場合は True、最初の式が 2 番目の式の正規表現の一致ではない場合は False です。

コード化されたオートメーション API 「VerifyIsRegexMatch」の使用については、以下の例をご覧ください。

  1. 例 1: 文字列が有効なメール アドレスかどうかを 確認する。
    string email = "test@example.com";
    string emailRegex = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
    bool isEmailValid = testing.VerifyIsRegexMatch(email, emailRegex);
    string email = "test@example.com";
    string emailRegex = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
    bool isEmailValid = testing.VerifyIsRegexMatch(email, emailRegex);
    
  2. 例 2: 文字列に何らかの数字が含まれているかどうかを 確認する。
    string text = "Hello, World 123!";
    string digitRegex = @"\d";
    bool containsDigits = testing.VerifyIsRegexMatch(text, digitRegex);
    string text = "Hello, World 123!";
    string digitRegex = @"\d";
    bool containsDigits = testing.VerifyIsRegexMatch(text, digitRegex);
    
  3. 例 3: 文字列が有効な 16 進数カラー コードかどうかを確認します。
    string color = "#FF5733";
    string hexColorRegex = "^#(?:[0-9a-fA-F]{3}){1,2}$";
    bool isColorValid = testing.VerifyIsRegexMatch(color, hexColorRegex);
    string color = "#FF5733";
    string hexColorRegex = "^#(?:[0-9a-fA-F]{3}){1,2}$";
    bool isColorValid = testing.VerifyIsRegexMatch(color, hexColorRegex);
    

outputMessageFormat を設定する

outputMessageFormat パラメーターは、検証操作で使用される値のプレースホルダーとして機能する、サポートされている引数を使用して設定できます。これらのプレースホルダーには、実行時にコード化されたオートメーション API を呼び出すときに定義した変数または値が自動的に入力されます。

コード化されたオートメーション API「VerifyRange」では、サポートされている次の引数を出力メッセージの作成時に実装できます。

  • {LeftExpression}: firstExpression パラメーターに指定した最初の式の値を表します。
  • {LeftExpressionText}: firstExpression パラメーターに挿入した最初の式のテキストを表します。
  • {RightExpression}: secondExpression パラメーターに指定した 2 番目の式の値を表します。
  • {RightExpressionText}: secondExpression パラメーターに挿入した 2 番目の式のテキストを表します。
  • {Result}: 検証結果であるコード化されたオートメーション API の戻り値を表します。

以下は、outputMessageFormat パラメーターの設定を含む、コード化されたオートメーション API「VerifyIsRegexMatch」の使用方法の例です。

// Initialize variables for the expressions to be verified
var expression1 = "(\W|^)stock\stips(\W|$)";
var expression2 = "(\W|^)stock\s{0,3}tips(\W|$)";

// Employ the VerifyIsRegexMatch coded automation API, with the last string parameter being the outputMessageFormat
testing.VerifyIsRegexMatch(expression1, expression2, "{LeftExpression} should match {LowerLimitText}, but the result is {Result}.");
// Initialize variables for the expressions to be verified
var expression1 = "(\W|^)stock\stips(\W|$)";
var expression2 = "(\W|^)stock\s{0,3}tips(\W|$)";

// Employ the VerifyIsRegexMatch coded automation API, with the last string parameter being the outputMessageFormat
testing.VerifyIsRegexMatch(expression1, expression2, "{LeftExpression} should match {LowerLimitText}, but the result is {Result}.");

この例では、中括弧内のプレースホルダーが実行時に対応する変数名とその値に置き換えられ、カスタマイズされた出力メッセージが提供されます。

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得