0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Power Appsで文字列を抜き出す方法を以下の3通りに分けて紹介します。

  • 最初に出現する文字より前の部分を取得したい場合
  • 文字と文字の間を抜き出す場合
  • 不要な文字列の削除による抜き出し

最初に出現する文字より前の部分を取得したい場合

Left関数+Find関数

Excelでもよく使用される、Left関数+Find関数です。

image.png

検索する文字を含めたくなければ、Len関数を使用してFind関数の出力から文字数分引きます。

image.png

Split関数+First関数

Find + Leftよりもコードが短くなるのでよく利用します。

image.png

Split関数で「.」を区切り文字にして文字列をテーブルに変換し、その一番上の値を取得することで指定した文字よりも前の文字列を抜き出しています。

image.png

文字と文字の間を抜き出す場合

Match関数

これまでの手法を組み合わせることでも文字列を抜き出すことが可能ですが、Match関数を使用すればより短く記述することが可能です。

image.png
最初の「.」から最後の「.」までを抜き出す場合

image.png
最初の「.」から2番目の「.」まで抜き出す場合

Split関数+Index関数

Split関数で作成された区切り文字ごとのテーブルから、Index関数を使用して何番目の部分を抜き出すかを指定することができます。

image.png
image.png

MatchAll関数+Index関数

Split関数の代わりにMatchAll関数を使用しても同様の処理が可能です。

image.png
image.png

不要な文字列の削除による抜き出し

不要な文字列のみ削除・置換することで必要な文字列を抜き出す場合は、Substitute関数を用いて不要な部分を削除します。

また、抜き出した後の文字列に不要な部分がある場合にも使用できます。

image.png

数値部分のみ抜き出す

数値部分のみ抜き出す場合は、MatchAll関数で正規表現使用します。

image.png

Power Automateはこちら

元記事

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?