How to split and extractt order number from text?

Hi , I am new to this group, i have an issue regarding splitting the order number from a random text.

for example: "This is regarding your order number: 123432
customer mobile number: 9876543210.
Please check and confirm the number, Thanks."

Please note that the order number will be mentioned as either “Order Number” or “order number”
some times the order number will be in 2nd line or in 4th line or anywhere in the text.
can anyone help me with this??

@Sharu_Wampire Can you Check this Workflow :
RegexFind.xaml (5.2 KB)

2 Likes

store entire string in variable named variable1
use assign activity : OrderNumber = variable1.substring(variable1.indexOf(“order number:”),6)

Assuming, order number is always six digits. Modify according to test results.

1 Like

Use regular expression with properties-
Input: Your text
Pattern: “(?<=order number:).*”

2 Likes

@supermanPunch thanks for your response, this works fine but what if there is some other names instead of order number?? the value doesnt change but there is possibility that name of the value might change for different scenarios. please help. Thanks

@Sharu_Wampire What are the other Possible Names that it can have?

1 Like

You can specify the other possibilities in or condition within regex pattern, like
“(?<=order number:|ord No:|OR NO:).*”

or

if you are sure of the pattern of the order number (ex: Order number starts with two letters and then 5 digits) and the occurrence (will be specified at the top), then you can write regex pattern to match only the order number and not refer the adjacent elements
“[A_Za-z]{2}[0-9]{5}”

3 Likes

@supermanPunch okay, forget abt names , i need to extract int value which is of 9 digits(length).
example: “The Order has been shipped with
sub no:1234 and same will be delivered by //****.
number:123456789
Thank you.”
In the above text, want to extract 9 digit value irrespective of name and it may be mentioned either in 1st line or 2nd line or 3,4,5 anywhere in the given text.
Thanks in Advance.

@Sharu_Wampire If the length is fixed to 9 digits, and there isn’t any other Number which has 9 Digits which you don’t want to Extract, then you can just use this regex :
\d{9}

@supermanPunch Thanks a lot, it works, but for some scenarios it is giving error where there is no int value.

@Sharu_Wampire What is the error it gives?

image

mytext=" This is regarding your order.
Please check and confirm the same, Thanks"

In the above text it only contains string,

@supermanPunch

@Sharu_Wampire I guess you are using Matches Activity, So it has an output matches.

Firstly, Check using an If Condition matches.Count>0
If true, Use the expression matches(0).ToString
else
Leave Blank.

This should solve the Error. Let me Know if any other problem you face when performing this step.

@supermanPunch Can you please modify this Number_Extraction.xaml (4.7 KB) , Thanks.

@Sharu_Wampire Check this Workflow :
Number_Extraction.xaml (6.4 KB)

1 Like

@supermanPunch it works, Thanks for that. But giving me wrong output, it is extracting first 7 digits from the value.
Suppose text file have 1234567689 in first line, and 1234567 in second line, as per my requirement , it should only check for 7 digits value and it shouldn’t select first 7 digits from whole value. It is bit confusing for me.

@Sharu_Wampire So you want it to Select the Second line value ?

@supermanPunch No, its not like 2nd line value, but i want only 7 digits value irrespective of the line it is present in.
For example: text contains, “line1: 123
line2: 1234
line3: 12345
line4: 1234567
line5: 12345678”
now from the above text i want 4th line value which the length is 7.

@Sharu_Wampire Im getting a bit confused, :sweat_smile:. Can you tell me what should be the output for this String :
" This is regarding your order. 123456789
Please check and confirm the same, 1234567 Thanks"

This way I can get to know what exactly is needed.