Hello there.
I need to extract exatly first word (actually number) of Outlook message body.
There can be spaces or “enter” symbols before first word and any other text after first word. Extracting should ignore them.
Can anyone help?
Thank you.!
Hi,
You can refer the following code.
saveMail.xaml (7.3 KB)
System.Text.RegularExpressions.Regex.Replace(item.Body ,“\D”,“”) will leave out all the characters and take only the numbers.
Thanks.
Thank you for answer but your code takes all numbers, not first.
Hi @ironman
Give this one a go:
https://regex101.com/r/OqPADW/1
(?=\s|\w)\d+
This one will return the first match:
System.Text.RegularExpressions.Regex.Match(item.Body, "(?=\s|\w)\d+").ToString
Hello @ironman
Try this
system.Text.RegularExpressions.Regex.Match(item.Body, “[1]”).ToString
-
0-9 ↩︎
Thank you. It works well. Can you help with code that does same but also takes characters and symbols in first word? Message could have that
or that format:
Code should extract only marked string.
Thanks!
Thank you. It works well. Can you help with code that does same but also takes characters and symbols in first word? Message could have that
or that format:
Thanks!
This one is a bit more tricky. Could you provide a sample with actual text and also clarify if the first 5 characters from the second example are always the same?
Yes, first 5 characters are always same: “ОБ00-”
This code works well. Thank you very much for your time.