Get a specific expression from a string - after a certain word

Hello,

I have the following expression

“DK call: AB.1227.12
Notice call:”

I need to extract: AB.1227.12 and I tried all the Regex expression I know, but none of them worked. Do you have any idea how can I always extract what is between “DK call:” and “Notice call” because I have a large pdf document and this expression will repeat all the time and I need to store those values.

Thanks in advance!

TRY THIS

this works if you have same pattern

Hope this helps

grafik

strText = your Text
strPattern = (?<=DK call:).*

strValue = System.Text.RegularExpressions.Regex.Match(strText, strPattern).Value.Trim()


if both the words are constant you can try this

Hi @darie.leolea

Input= "DK call: AB.1227.12
        Notice call:"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=DK\scall:\s).+").Value

Hope it helps!!

When the text which is to extract over multiple lines we would do:

grafik

You can try this way if both the “DK call: and Notice call:” are constant

STRINPUT : - “DK call: AB.1227.12
Notice call:”

STRINPUT.Split({"DK call:"},StringSplitOptions.RemoveEmptyEntries)(0).Split({"Notice call:"},StringSplitOptions.RemoveEmptyEntries)(0).Trim

output : -

@darie.leolea

1 Like

Hi @darie.leolea

Try this

System.Text.RegularExpressions.Regex.Match(Input,"(?<=DK call:\s+).*\n(?=Notice call)").Value

you can try this regex expression it will work and it will only pick the text from from the in between
DK call: and Notice call:

(?<=DK call:)\s{0,}.*\s{0,}(?=Notice call:)

STRINPUT : - “DK call: AB.1227.12
Notice call:”

try this in assign activity

System.Text.RegularExpressions.Regex.Match(STRINPUT,"(?<=DK call:)\s{0,}.*\s{0,}(?=Notice call:)").Value.Trim

output : -
image

@darie.leolea

Hi @darie.leolea

System.Text.RegularExpressions.Regex.Match(Input,"((?<=:\s*).*\d+)").Value

image

Hope this helps!!

Hi
Try this expression
Output_Val = Text.RegularExpressions.Regex.Match(“DK call: AB.1227.12”,“(?<=DK\scall:\s).+”).ToString

Thank you

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