My text is as following and I want to extract the number at the end:
Order number 12345
Confirmation Number 12345
I have used this regex: (?:Order number|Confirmation Number)\s(\d+)
(I am getting this text through outlook email; sometimes it can come Order Number 12345 and sometimes it comes Confirmation Number 12345. Then its ok. But when these both comes togather then this regex extracts same number twice)
Fine
if its a match or if its a group we can get the first one alone with the index position like this matchvariable(0).tostring
or matchvariable.Group(0).tostring
Text 3: Please find Order number 23456 and also Confirmation Number 23456.
Text 4: Here there is a word Order number but number is not available
Text 5: Here there is a word Confirmation Number but number is not available
I am using “Get outlook mail messages” and iterates via “for each” activity
I am assigning String variable “EmailBodyText” to extract each email’s full body text. And then
Number = System.Text.RegularExpressions.Regex.Matches(EmailBodyText, “(?:Order number|Confirmation Number)\s(\d+)”)(0).Groups(1).Value
(I tried here Match instead of Matches also but didn’t worked)
When robot iterates through first transaction, I would like to extract 12345, second time 34567 and third time 23456 and in case of 4th and 5th text it should reply back to sender.
Can anybody suggest logic for this?
Thank you and sorry if I haven’t clearly explained situation before!!
i think if for every line you need to check, if the number present is only the one you need, then you could just use: \d+ expression, and if no matches you know you have the case 4 or 5…
Email body contains signature that’s why there are mobile numbers and other kind of numbers present, so I cannot use only \d+ expression, so far I have tried following expression,
Number = System.Text.RegularExpressions.Regex.Matches(EmailBodyText, “(?:Order number|Confirmation Number)\s(\d+)”)(0).Groups(1).Value
it will be impossible to help if you are not very clear in what you need… you are the one who know your requisites, if you give us the wrong examples, then people give you solutions that you after say is not good
Hi @bcorrea, my apologies if I was not very clear while simplifying my actual problem! I always appreciate every suggestions. But thank you for your time and efforts!