Split text from captured text

Please help to do extract the values from below example texts

Text 1 :CA- - Plant 4001 - CoCode 4001

Need text available after CoCode

Expected output : 4001

Text 2 : [4001] HCS Inc USA

Value Inside [ * ] bracket

Expected output : 4001

Text 3 : [PIND] HMP Indirect Procurement Ariba

Value Inside [ * ] bracket

Expected output : PIND

1 Like

Stroutput = Split(Strinput.ToString, β€œCoCode”)(1).ToString.Trim

stroutput = System.Text.RegularExpressions.Regex.Match(Strinput.ToString, β€œ\[(.*?)\]”).Groups(β€œ1”).Value

Same as above

Explanation

Cheers @Sathish_Kumar_S

1 Like

Hi @Sathish_Kumar_S

Matches1 = System.Text.RegularExpressions.Regex.Match(β€œCA- - Plant 4001 - CoCode 4001”, β€œ(?<=CoCode\s+)\d+”).Value
image

Matches2 = System.Text.RegularExpressions.Regex.Match(" [4001] HCS Inc USA", β€œ(?<=[)\d+”).Value
image

Matches2 = System.Text.RegularExpressions.Regex.Match(" [PIND] HMP Indirect Procurement Ariba", β€œ(?<=[)[A-Z]+”).Value
image

1 Like

@Sathish_Kumar_S

Please try these

Str.Split({"CoCode"},Stringsplitoptions.None)(1)

Str.Split({"[","]"},3,Stringsplitoptions.None)(1)

Or using regex

(?<=CoCode\s*).*

(?<=\[).*(?=\])

Cheers

1 Like

Hope it’s clarified @Sathish_Kumar_S

1 Like

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