LoginSignup
2
0

More than 5 years have passed since last update.

UiPathでテキストファイルの文字列置換を行う

Posted at

あるテキストファイルにある文字列を別の文字列に置換する方法

置換する方法1

  1. ReadTextFileアクティビティで対象のファイルを読み込む(プロパティのエンコーディング設定を忘れずに)
  2. Assignアクティビティの右辺にを入れると置換された文字列が左辺に出力される。
    読み込んだテキストを格納した変数.Replace(置換前文字列,置換後文字列)
ワークフロー例

・sample.txt
読み込むテキストファイル
・temp
読み込んだテキストを格納する変数
・result
変換後の結果を格納する変数
・Assignの右辺
temp.Replace("hello","good by")

image.png

実行結果

image.png

置換する方法2

  1. ReadTextFileアクティビティで対象のファイルを読み込む(プロパティのエンコーディング設定を忘れずに)
  2. Microsoft.Activities.Expressions.ReplaceStringアクティビティを利用する。
    プロパティのExistingValueに変換前の文字列
    Inputに変換対象のテキストを格納する変数
    Replacementに変換後の文字列
    Resultに変換結果を格納する変数
    を設定する。
ワークフロー例

・sample.txt
読み込むテキストファイル
・temp
読み込んだテキストを格納する変数
・result
変換後の結果を格納する変数

image.png
ReplaceStringアクティビティのプロパティ
image.png

実行結果

image.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0