I have following string and want to extract multiple values (all marked as bold/green) using single Regex. Is it even possible?i want to store these values in group and then write them in Excel.
* 26/10/19 AAAA/5555555 Z**ZZZ200000-1** 888/8 555 25252
8888888
D shipments: **AAAA BBBB 25,00**
D shipments: **CCCC DDDD 20,00**
Additional services:
- HAZARDOUS GOODS SURCHARGE CH **124.00**
- Subsidy for reduction of farm fees **123,00**
**1000,00** 06
GTW:00/99999999 **NNNN-UUUU-SSSS-TTTT**
@Robott - can you share an example of what you want the output to look like? I’m not sure I understand. For example, do you want an output to looks like 2610195555555…0099999999 all in a single cell? Or do you want each set of numbers in it’s own cell like 26|10|19|5555555|…|00|99999999 ? Or something completely different?
the one i sent will put them in groups with one expression, just some chars were lost in the forum format, look at that one: ([0-9]{2}\/[0-9]{2}\/[0-9]{2})|(ZZZ[0-9]{6}-[0-9])|([A-Z]{4} [A-Z]{4} [0-9]{2},[0-9]{2})|([0-9]+[\.,][0-9]{2})|([A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4})
you will use Matches activity and the result will be Match.Groups and their indexes, run it and with debugger you will be able to get all values found…
actually no, in Matches will have each one with a column in your excel, so you cant use a loop there for every add data row… you need to use the loop to create the Array Row and after you add a row:
Matches(0)=26/10/19
Matches(1)= ZZZ20000-1
…
Why not make a regex that will parse all needed elements in one go like this (?<gr1>[0-9]{2}\/[0-9]{2}\/[0-9]{2}).*?(?<gr2>ZZZZ[0-9]{6}-[0-9]).*?(?<gr3>[A-Z]{4} [A-Z]{4} [0-9]{2},[0-9]{2}).*?(?<gr4>[0-9]+[\.,][0-9]{2}).*?(?<gr5>[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4})
Then get each element as named group like this
For Each match
element1 = match.groups(“gr1”)
element2 = match.groups(“gr2”)
datatable.addrow
Next