WANT TO REPLACE THE VALUES

UNB+UNOA:3+QAMORRISONSHUB:ZZ+QAMORRISONSTP1:ZZ+220701:0742+1421++ORDERS’
UNH+142100001+ORDERS:D:96A:UN’
BGM+220+13521354+9’
DTM+4:20220701:102’
DTM+137:20220701:102’
DTM+64:20220708112000:204’
DTM+63:20220708112000:204’
DTM+200:20220701:102’
FTX+AAB+++30th Day of 2nd Month, Discount 0%’
FTX+COI+++ATTN?: ORDER DEPARTMENT. – DELIVERY CONFIRMED FOR 11.20 ON 8/07/22 --P:LEASE NOTE THAT THIS BOOKING IN TIME MUST BE STRICTLY ADHERED TO. VEHI:CLES ARRIVING EITHER EARLY OR LATE WILL BE ASKED TO WAIT FOR THE NEXT:AVAILABLE SLOT. ADDITIONAL INFORMATION?: In case of order query please:telephone?: Fresh 0845 611 5000 / Ambient 0845 611 5601 In case of deli’
FTX+COI+++very query please telephone 01795 518638’
NAD+BY+5010251000006::9+WM. MORRISON SUPERMARKETS PLC:HILMORE HOUSE:GAIN LANE:BRADFORD:BD3 7DL’
NAD+SU+08000859801808::9+Macphie Of Glenbervie (IWF):GLENBERVIE:NULL:STONEHAVEN:AB39 3YG+STONEHAVEN’
RFF+IA:9793’
NAD+DP+5010251007814::9+FLEETEND WAY:G PARK:KEMSLEY:SITTINGBOURNEKEN:GBME10 2FD’
CUX+5:GBP’ALC+A++++FA:::00000000000000000000’
LIN+1++05017506411617:EN’
PIA+1+109942659:IN’
IMD+++:::PIN?: [1 X] (B) MACPHIE NON HYDROGEN:ATED SWEET SNOW 12.5KG’
QTY+21:84’
PRI+AAA:13.65’
UNS+S’
CNT+2:1’
UNT+24+142100001’
UNZ+1+1421’

For the above text i using below regex expression
(?<=+)[A-Z0-9]+(?=:ZZ)
the regex is throwing correct value only

but ZZ will always not be there it can be any other value
can someone suggest general regex for the matches
match1 - QAMORRISONSHUB
match2 - QAMORRISONSTP1

@ajindal

Few questions here

  1. Will the colon be present and will the value after colon if its not ZZ will it be two characters only?
  2. The value you need is always containing 14 characters?

If the above is yes then try this

[A-Z0-9]{14}(?=:[A-Z]{2})

Cheers

Hi @ajindal

You can use the below regex expression to extract the required output.

Best Regards.

Thanks
UNB+UNOA:2+5060171360001+5027367999995+221222:0900+1441’
UNH+144100001+ORDERS:D:96A:UN’
BGM+220+4502020596+9’
DTM+137:20221222:102’
DTM+261:20221222:102’
DTM+10:20221231:102’
FTX+ZZZ+++On order:1’
NAD+BY+5060171360001’
NAD+VN+0002000848+18+Moet Hennessy Uk Limited+Grosvenor Gardens:X+London++SW1W 0DH’
LOC+159+5027367999995’
RFF+VA:GB238953231’
CTA+OC+:Stonard Sam’
COM+ 0845 362 03 45:TE’
COM+ 01506 508 739:FX’
NAD+DP+5060171360001+2+2+Runnymede CDC:1215 Windsor Road Egham Surrey T+Surrey+SY+TW20 0AE’
CTA+OC+:GOODS IN’
COM+ 01784 4717:TE’
NAD+IV+5060171360001+906+WORLD DUTYFREE EUROPE LTD+WDFG UK LTD:FELTHAM+4 New Square, Bedfont Lakes+LO+TW14 8HA’

it is not working for this code.Also it is taking others value too

no it 14 is not fixed
UNB+UNOA:2+5060171360001+5027367999995+221222:0900+1441’
UNH+144100001+ORDERS:D:96A:UN’
BGM+220+4502020596+9’
DTM+137:20221222:102’
DTM+261:20221222:102’
DTM+10:20221231:102’
FTX+ZZZ+++On order:1’
NAD+BY+5060171360001’
NAD+VN+0002000848+18+Moet Hennessy Uk Limited+Grosvenor Gardens:X+London++SW1W 0DH’
LOC+159+5027367999995’
RFF+VA:GB238953231’
CTA+OC+:Stonard Sam’
COM+ 0845 362 03 45:TE’
COM+ 01506 508 739:FX’
NAD+DP+5060171360001+2+2+Runnymede CDC:1215 Windsor Road Egham Surrey T+Surrey+SY+TW20 0AE’
CTA+OC+:GOODS IN’
COM+ 01784 4717:TE’
NAD+IV+5060171360001+906+WORLD DUTYFREE EUROPE LTD+WDFG UK LTD:FELTHAM+4 New Square, Bedfont Lakes+LO+TW14 8HA’
CTA+OC+:INT_POAP_P91’
COM+ 0208 2434:TE’
NAD+SU+5027367000004’
CUX+1:GBP’
PAT+1+1:::DAP’
TDT+25++:3’
LIN+10++000000001000160:IN’
PIA+1+3245995567528:VN+1055675:VS+12:IZ’
IMD+F++:::Hennessy VSOP 40% 100cl’
QTY+21:60’
DTM+132:20221231:102’
MOA+203:15429.6’
PRI+INF:257.16’
LIN+20++000000001076963:IN’
PIA+1+3245998442921:VN+1100936:VS+6:IZ’
IMD+F++:::Hennessy VSOP 40% 70cl’
QTY+21:112’
DTM+132:20221231:102’
MOA+203:15160.32’
PRI+INF:135.36’
LIN+30++000000001000614:IN’
PIA+1+3185370396391:VN+1040593:VS+6:IZ’
IMD+F++:::M&C Nectar 75cl’
QTY+21:21’
DTM+132:20221231:102’
MOA+203:2574.18’
PRI+INF:122.58’
LIN+40++000000003455972:IN’
PIA+1+3245998679228:VN+1092886:VS+6:IZ’
IMD+F++:::Hennessy XXO 40% 100cl’

for this i want
match1:- 5060171360001
match2:- 5027367999995

@ajindal

Please try this…this will match both values together…after getting the data split the retrieved data using plus (+) sign and then get both values separately

(?<=UNB\+UNOA:[0-9]\+).*(?=[0-9]{6}:)

ExtractedValue.Split({"+"},Stringsplitoptions.None). This will give you array of values

Cheers

What do you want to be extract from this data? @ajindal

match1- 5060171360001
match2- 5027367999995

i am storing the regex match in a matchcollection data type and it is not having split

Hi @ajindal

You can use the below regular expression for this. Check below,

  • System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((?<=(UNB+UNOA:\d*+)|(\d++\d++))(\d+)(?=+\d+))”)

Hope it helps!!

@ajindal

Match collection can be looped in for loop and then inside use a split

Or matchcol(0).Value.split… will work

Cheers


error here

it is fetching mutilple values i just need the first two matches

@ajindal

When you say multiple an you say what are it is picking?

if you need only first two then use (0) only and dont use remaining

cheers

No @ajindal. There is no error in screenshot it shows the pattern error, that means Look a head doesn’t allow in some application. This will not effect yours you can use the regular expression.

image
it is having error

You cant use *+ in regex particulary in c# or vb. Other language might support it