1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[PADフロー] PADフロー整形

Last updated at Posted at 2023-09-23

Power Automate Desktopの、フローを整形するフローです。
クリップボード上で処理します。
# [ControlRepository][PowerAutomateDesktop] 以降のJSON部分を処理します。

整形内容

  • 改行
  • セレクタの要素名の、シングルクォーテーション部分を削除
  • スクリーンショット削除(ScreenShot/ScreenshotPathnullにする)
PADフロー整形.robin
Clipboard.GetText Text=> ClipboardText
Text.ParseText.RegexParseForFirstOccurrence Text: ClipboardText TextToFind: $'''(?m)^(?=\\{\\s+\"ControlRepositorySymbols\": \\[)''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position
IF Position = (-1) THEN
    EXIT Code: 0
END
Text.GetSubtext.GetSubtextFromStartTo Text: ClipboardText NumberOfChars: Position Subtext=> Robin
Text.GetSubtext.GetSubtextFrom Text: ClipboardText CharacterPosition: Position Subtext=> Json
Text.Replace Text: Json TextToFind: $'''(?<=\\\\r\\\\n)''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''\\n      ''' ActivateEscapeSequences: True Result=> Json
Text.Replace Text: Json TextToFind: $'''(?m)(?<=^ {21,}\\\\\"Name\\\\\": \\\\\"[^\'\\n]+) \'.+\'(?=\\\\\")''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> Json
Text.Replace Text: Json TextToFind: $'''(?m)(?<=^\\s+\\\\\"ScreenShot\\\\\": )\\\\\"[^\"]+\\\\\"''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''null''' ActivateEscapeSequences: False Result=> Json
Text.Replace Text: Json TextToFind: $'''(?m)(?<=^\\s+\\\\\"ScreenshotPath\\\\\": )\\\\\"[^\"]+\\\\\"''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''null''' ActivateEscapeSequences: False Result=> Json
Clipboard.SetText Text: $'''%Robin%%Json%'''

使っている正規表現をメモしておきます。
リファレンスは正規表現言語 - クイック リファレンス - .NET | Microsoft Learn
確認はregex101の.NET(C#) FLAVOR が便利です。

改行
(?<=\\r\\n)
シングルクォーテーション部分
(?m)(?<=^ {21,}\\"Name\\": \\"[^'\n]+) '.+'(?=\\")
ScreenShot
(?m)(?<=^\s+\\"ScreenShot\\": )\\"[^"]+\\"
ScreenshotPath
(?m)(?<=^\s+\\"ScreenshotPath\\": )\\"[^"]+\\"
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?