Extract a specific part from a long string

studio

#1

Hello Everyone !!
I know there are a lot of questions out there about this, but none of them match what i actually want. so here is my question:

What I am trying to do here is extract a specific part from a long string
so
Example : FW: REVISED PO REQUEST: CRL PO# 6600551653 for Cell Culture SH30071.03HI
Result : 6600551653
the thing is that the PO# does not always only have a numbers but can also have a combination of many characters

Thanks to you all for your responses in advance !!


#2

Hi zfaddi ,
I have attached a workflow go through it and let me know if you face any problem.splitstring.zip (2.2 KB)


#3

It is also possible with 1 assign activity:
image

See attached workflow for more information.
ExtractString.xaml (5.3 KB)

Don’t forget to import this namespace in your project: image


#4

Hello MahalingPatil
Thank you soooo much for your response it helped a lot. But I was wondering is there a work around this exception. because once I run this string through the code I get an empty string as a result.

Example: “FW: Andrew : Biogen PO#934358 sales order 755063”
Expected result : “934358”
Actual result : “”

I would really appreciate your help on this again, and thanks a lot !!


#5

This comes from regex formula matching nothing. It needs to be corrected.
However, this knowledge of the structure of the PO number is needed. You’ve mentioned that it can contain other characters. Could you give an example? Also, is it always of same length?


#6

The PO number could be any combination of character, and also could be any length,
so an example would be: "Fwd: EXT: RE: P.O Q-00497400V1, Quote# 49923 "
expected result : “Q-00497400V1”


#7

Please try with this Regex:
(?<=P\.O |PO# |PO#).+(?= sales|,| for)
Take a note of its structure, as you might have to modify based on the different conditions:
The basics are this:

  1. (?<=P.O |PO# |PO#) - here you have what should proceed your PO number, add new ones after the |
  2. .+ - here is when the selection of the PO happens
  3. (?= sales|,| for) - here you have what is after, again, add new ones after |

The full Regex should match the PO numbers from the following lines:
FW: REVISED PO REQUEST: CRL PO# 6600551653 for Cell Culture SH30071.03HI
Fwd: EXT: RE: P.O Q-00497400V1, Quote# 49923
FW: Andrew : Biogen PO#934358 sales order 755063


#8

Hi @zfaddi ,
I have done some of the changes in the workflow and attached it go through it and let me know.splitstring.zip (2.3 KB)