Regexproblem

Hi team,
I have two different statement i want ref no

  1. N340222234818715TXN REF
  2. 2301060010001508 REF NO

N340222234818715 and 2301060010001508 I want this as output in regex form

Hi @Kuldeep_Pandey please try this,
testStr=“your values”

  1. System.Text.RegularExpressions.Regex.Match(testStr,“.+(?=TXN\s+REF)”).ToString
  2. System.Text.RegularExpressions.Regex.Match(testStr,“.+(?=\s+REF\s+NO)”).ToString

Hi @Kuldeep_Pandey

Checkout thois expression

System.Text.RegularExpressions.Regex.Match(InputString,"^\S+").ToString

In 1 TXN is also coming in don’t want this

Checkout this expression

System.Text.RegularExpressions.Regex.Match(InputString,"^\S{16}").ToString

EFT INCOMING
N340222234818715 NEFT IN
UTR CITIN22377099474
FROM ASAHI INDIA GLASS
LTD GUR
N340222234818715TXN REF
NO 30940
TRN REF NO:D01ZOAC223401Do0
is this regex statement will work in this?

This is what you need right ? @Kuldeep_Pandey

2nd one I need

Only N340222234818715 you need @Tapan_Behera1 ?

If yes you can try this @Kuldeep_Pandey

System.Text.RegularExpressions.Regex.Match(InputString,"^\S{16}(?=TXN)").ToString

@Kuldeep_Pandey

Please try this

(?=N)\S{16}(?=.*REF)

System.Text.RegularExpressions.Regex.Match(InputString,"(?=N)\S{16}(?=.*REF)").ToString`

Hope this is what youa re looking for… what it check is if there is ref and the balue starts with N and 16 characters

Cheers

  1. 2301060010001508 REF NO
    is this will work for this also?

@Kuldeep_Pandey

A small modification fir this to work, change regex as below

(?=N|)\S{16}(?=.*REF)

Cheers

You can try this

System.Text.RegularExpressions.Regex.Match(InputString,"^\S{16}(?=TXN)|\S{16}(?=\sREF NO)").ToString

Hope this Helps

Regards
Sudharsan