Splitting the large string

Hi Guys,

I wanted to split the large string which comes from excel. find the Below string

AARP Supplementa DES:HCCLAIMPMT ID:800564919 INDN:INTEGRATED REGIONAL LA CO ID:1362739571 CCD PMT INFO:TRN115689632061362739571000036273-

In the above string i wanted to get only number after TRN i.e 1568963206.

Help me !!

Hey Vinutha, use the Expression below:

System.Text.RegularExpressions.Regex.Match(strInput,"(?<=TRN).*(?=-)").Value

where strInput is a variable with your input.

Kind regards, Anders

1 Like

Hi @AndersJensen

Thank you !!

From your expression am getting two values.

I need only the highlighted number i.e inbtween * how can i get it?

@AndersJensen

sample.xlsx (8.7 KB)

i have attached the excel files for the reference.

You can simple modify the expression, in laymans terms:

  • (?<=TRN) defines a lookbehind
  • (?=-) defines a lookahead
    meaning we are telling our code to look in between.

Untitled

  • which will get the value from your screenshot.

For further reference, I can recommend @Steven_McKeering awesome post here, Regex help tutorial MEGAPOST – Making your first Regex post, Reusable Regex Patterns, Regex Troubleshooting, Sample Workflow and more

1 Like

Thank you @AndersJensen

I got it!!

1 Like