Extract part of string

Hi All,
I am having the string
example-(claim# -4412
Property Owner -senor frogs
date of loss- jan21,2019)
So I want to get only claim#-4412( only that part ie. written before the property owner .
so how can I use it. I have used many ways to split and trim the string ,but it doesn’t work.
Please help.
for reference Property owner will always be same

Hi @arpita2,

If property owner will always be same then you can use below regular expression


You can try the above expression in https://regex101.com/r/CczI9a/1

First you need to import system.text.regularexpressions

Then use the below expression like this

Regex.match(InputString,“The above Pattern”).tostring

The output of above will be claim# -4412 , if you want to remove space from this string use replace method of Regex

Regex.replace(Output of above expression," “,”")

Now the output will be without space claim#-4412

Regex is your friend https://regex101.com/r/IyYHqi/1

Try this,

Thanks @anil5
I have done all these things as suggested by you , but I got empty value in message box.
my result should be claim# -4412.
can you explain = Regex.match(InputString,“The above Pattern”).tostring = what will be the above pattern.
or can you please provide the solution.

The above pattern is “(.+?)(?=\nProperty)”

Can you provide your workflow so i can see what wrong or mistake you have done and correct it

Refer the below workflow for reference

I have stored the below input in a text file and then processed.

claim# -4412
Property Owner -senor frogs
date of loss- jan21,2019

Sequence11.xaml (5.8 KB)

thanks @anil5,
but it gives me blank message box.
so what should I do?

Debug. There is enough information in this thread to extract the info.

You have to just look into this, I think ur input is wrong or is in different format

I have not used message box at all