Splitting a String1

Hi All,

I need to split a string “3057020000325199:MATM 1215091318561170300132”
from the above expression I just need “121509131856” i mean I just need to consider
12 number after"MATM" no need to consider before MATM.

Please help me on this.

Thanks

Hi @HeartCatcher

Try Splitting By Space and Take Index 1 value from Split and SubString(0,12) will Provide the result.

sttingValue is the Input String

image

Regards

1 Like

grafik

myString = System.Text.RegularExpressions.Regex.Match(YourStringVar, "(?<=MATM )\d{12}").toString

2 Likes

Hi

It’s the same way how we used a split method in your previous query

Here instead of space we will use MATM as a separator

Like this

Str_output = Split(Str_input.ToString,”MATM”)(1).ToString.SubString(0,12)

Here MATM is considered as a separator and in Substring 0 represent the first character and 12 will consider the first twelve letters from 0 position

It’s as simple as that

Cheers @HeartCatcher

2 Likes

hi ,

(str) Str1=“3057020000325199:MATM 1215091318561170300132”
(int32) StrLenght=Str1.length
(int32) int1=Str1.indexOf(“MATM”)
Str2=Str1.Substring(Int1+4,length-(Int1+4))

Hello @ppr ,

Can you please explain how (?<= ) works?

Thanks

got explained from Regex101.com with

grafik

https://www.rexegg.com/regex-lookarounds.html

1 Like

hii
you can try like this

output

Hi @HeartCatcher
Is this resolved

Hi @Palaniyappan ,
It Does Work thanks for your contribution.

1 Like

HI @ppr,

Thanks for the support.

Hi @adarsh_kotagiri ,

Thank you.

@takyysh .
Thanks.

@pravin_calvin ,

Thank you so much.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.