Sentence between two words

hi, I want to get sentence between Report and Read from below

Australian Market Report - Australian shares rally after nudging 12-month lows\n Read\n more\n \n

Report and read is constant but in between those words will change

Hi @sshitol

(?<=Report\s+\-\s+).*(?=\s+Read)

System.Text.RegularExpressions.Regex.Match(Input,"(?<=Report\s+\-\s+).*(?=\s+Read)").Value

Hope this helps!!

You can use regex to extract the data between two words, this is how we can implement in UiPath.

System.Text.RegularExpressions.Regex.Match("Australian Market Report - Australian shares rally after nudging 12-month lows\n Read\n more\n \n", "(?<=Report\s+\-\s+).*(?=\s+Read)").Value.Trim

Thanks,
Vinit Mhatre

HI,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?i)(?<=\breport\W+)\w[\s\S]*?(?=\W+read\b)").Value

Regards,

Hi @sshitol

Input= "Australian Market Report - Australian shares rally after nudging 12-month lows\n Read\n more\n \n"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Report\s*\-\s*).*(?=\sRead)").Value

Hope it helps!!

its capturing /n as well, but I dont want any /n, or special character or extra white spaces

Hi @sshitol
Try this:

Input= "Australian Market Report - Australian shares rally after nudging 12-month lows\n Read\n more\n \n"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Report\s*\-\s+).*(?=\\n\s+Read)").Value

Hope it helps!!

its giving blank op

Hi @sshitol

Try this

(?<=Report\s+\-\s+).*(?=\\n\s+Read)

Hi @sshitol

Use this regex:

(?<=Report\s*\-\s+).*(?=\\n\s*Read)

Regards

still blank output getting

still blank output coming

Can you please paste that input sample here @sshitol

Australian Market Report - Australian shares plung after nudging 12-\month\n Read\n more\n \n

@sshitol

It’s working

(?<=Report\s\-\s).*[A-Za-z]\s*(?=\\n\s+Read)

Can you please send the screenshot

in UiPath i m getting blank op

@sshitol

Can you please check whether the marketStr variable gives the value or not

@sshitol

System.Text.RegularExpressions.Regex.Match(Input,"(?<=Report\s+\-\s+).*(?=\\n\s+Read)").Value

see the screenshot

Hi @sshitol
Try this:

Input= "Australian Market Report - Australian shares rally after nudging 12-month lows
Read
 more"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Report\s*\-\s+).*(?=\s*Read)").Value

Regards,