要求 メール本文から必要な情報を抜き出して欲しい
RPAには基幹システムから自動送信されたメールを受診し、その本文の内容から必要なデータを読み込み、チェックするロボットがあります。
今回の要求は、受信されてくるメールの中から、以下のような情報を読み込んで欲しいと仮定します。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-121.png)
ワークフロー 概要
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-123.png)
このようなワークフローを使って、実際に文字列を抽出してみたいと思います。ポイントは「正規表現」と「一致する文字列を取得」アクティビティです。
正規表現を使って抽出する
このやり方にはいろんな抽出方法があります。例えば改行を1行1行ずつ分割するSplitメソッドの方法です。
その中でも今回は正規表現を使った抽出方法を使っていきましょう。
この赤枠で囲まれた単語は、どのような法則性を持っているでしょうか、まず一つは、先頭にコロンがついていること、そしてもう一つは最後が行末であることです。
コロンと行末の間に挟まれている任意の文字を抽出する
(?<=:).*(?=\r\n)
この正規表現を説明すると、
?<=:
コロンが前に位置している
.*
任意の文字が存在している
?=\r\n
行末が最後に位置している
正規表現チェッカーのサイトはこちらからです。
ちょっと改行のところが上手く認識しなかったので、 ドルマークで対応しています。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-119.png)
普通だったら正規表現ビルダーで見るんですけど、肯定否定の先読み後読みはちょっと対応していないみたいなので、正規表現チェッカーを使いました。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-120.png)
一致する文字列を変数 matches で返す
「一致する文字列」アクティビティは入力した文字列を正規表現で検索し、一致した値を変数「Matches」型で変えてしてくれます。
今回は、そのMatches型を「matches」として返してみます。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-122.png)
「一致する文字列を取得」アクティビティを通過した後、 ローカルパネルの値を参照してみます。「matches」の中に配列として4つ格納されました。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-125.png)
Matches型は「0」から順番に変数の値を返してくれます。
次の代入アクティビティで「登録ID」から順番にmatches(0).ToString で返していきます。
![](http://aftp.tokyo/wp-content/uploads/2020/01/image-126.png)
余談 これでも、まだエラーハンドリングが足りない。
おそらく、これだけでも十分に実装することは可能でしょう。しかし、もっとテストケースを入念に行う場合、本当に「登録ID – 氏名 – 登録日時 – 登録URL」の順番なのだろうか?というケースも考えるべきです。(もしくは、システム側に問い合わせて、本当にこの順番に変動はないのか問い合わせてみてもいいかもしれません)
一応、今回はここまで。
38件のフィードバック
Nice post. I was checking continuously this blog and I am
impressed! Extremely helpful info specially the last part 🙂 I care for such information a lot.
I was seeking this certain information for a long time.
Thank you and best of luck.
my homepage: vpn special coupon
I’m truly enjoying the design and layout
of your website. It’s a very easy on the eyes which makes it much
more enjoyable for me to come here and visit more
often. Did you hire out a designer to create your theme?
Great work!
Here is my web site vpn code 2024
Heya i am for the first time here. I came across this board and I find It truly useful &
it helped me out much. I hope to give something back and aid others like you aided me.
Also visit my site – vpn special coupon code 2024
I was curious if you ever considered changing
the structure of your website? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people
could connect with it better. Youve got an awful lot of text for only having one or 2 pictures.
Maybe you could space it out better?
Have a look at my web blog – vpn special coupon code 2024
Wonderful work! That is the kind of information that are supposed facebook vs eharmony to find love online be shared around
the net. Shame on the search engines for not positioning this post higher!
Come on over and discuss with my site . Thanks =)
I do accept as true with all the concepts you have presented for your
post. They’re really convincing and can definitely work.
Nonetheless, the posts are too short for beginners.
Could you please lengthen them a bit from subsequent time?
Thank you for the post.
Also visit my web site eharmony special coupon code 2024
You should take part in a contest for one of
the highest quality sites on the net. I most certainly will
recommend this site!
my blog … nordvpn special coupon code 2024
pharmacies in mexico that ship to usa: cmq mexican pharmacy online – medicine in mexico pharmacies
mexican border pharmacies shipping to usa: cmqpharma.com – mexican border pharmacies shipping to usa
I was reading through some of your articles on this site
and I think this web site is rattling instructive!
Keep posting.Leadership
canadian pharmacy 1 internet online drugstore: canada rx pharmacy – canadian pharmacy king reviews
reputable mexican pharmacies online: buying from online mexican pharmacy – п»їbest mexican online pharmacies
canadian pharmacy store: recommended canadian pharmacies – canadian pharmacy oxycodone
mexican rx online: best online pharmacies in mexico – mexican online pharmacies prescription drugs
drugs from canada: canadian pharmacy king reviews – online canadian pharmacy
cheapest online pharmacy india: cheapest online pharmacy india – indian pharmacy online
online pharmacy india: buy prescription drugs from india – buy medicines online in india
best online pharmacies in mexico: mexican pharmacy – pharmacies in mexico that ship to usa
reputable indian online pharmacy: reputable indian pharmacies – indian pharmacy
canadian pharmacy 365: rate canadian pharmacies – canadian pharmacy world reviews
mexican pharmaceuticals online: mexican rx online – buying prescription drugs in mexico
canadian drug: canadian pharmacy 365 – canadian pharmacy service
https://doxycyclinedelivery.pro/# doxycycline 20 mg capsules
http://amoxildelivery.pro/# where can i buy amoxicillin without prec
cost clomid no prescription [url=http://clomiddelivery.pro/#]where can i get cheap clomid without dr prescription[/url] where to get generic clomid without rx
http://clomiddelivery.pro/# can i buy clomid without prescription
http://doxycyclinedelivery.pro/# buy generic doxycycline 40mg
amoxicillin cost australia [url=https://amoxildelivery.pro/#]can you buy amoxicillin over the counter canada[/url] amoxicillin 500 mg tablets
https://paxloviddelivery.pro/# paxlovid buy
https://ciprodelivery.pro/# cipro for sale
ciprofloxacin 500 mg tablet price [url=https://ciprodelivery.pro/#]antibiotics cipro[/url] ciprofloxacin generic
http://clomiddelivery.pro/# where can i get cheap clomid
https://doxycyclinedelivery.pro/# doxycycline online for dogs
buy paxlovid online [url=https://paxloviddelivery.pro/#]paxlovid buy[/url] paxlovid pharmacy
https://ciprodelivery.pro/# buy ciprofloxacin
https://doxycyclinedelivery.pro/# doxycycline tablets where to buy
https://paxloviddelivery.pro/# п»їpaxlovid
paxlovid price [url=https://paxloviddelivery.pro/#]п»їpaxlovid[/url] п»їpaxlovid
https://ciprodelivery.pro/# buy cipro online
https://amoxildelivery.pro/# buy amoxicillin online uk
how to buy clomid online [url=http://clomiddelivery.pro/#]can i get generic clomid without insurance[/url] cost clomid without a prescription
http://paxloviddelivery.pro/# paxlovid buy
https://paxloviddelivery.pro/# paxlovid buy
amoxicillin 500 capsule [url=http://amoxildelivery.pro/#]buy amoxicillin 500mg canada[/url] buy amoxicillin 500mg canada
http://doxycyclinedelivery.pro/# can i buy doxycycline online