Retrieve a word in a line using regex

Hi All,
I need to extract the word which is after ivf.This line may occur anywhere in the file.How can we do it

string:“The text is ivf road”
o/p road

Hi @ranjani,

Suppose this is your string

“The text is ivf road”
“The text is ivf bus”
“The text is ivf train”
“The text is ivf car”

Use the below regex

(?<=ivf )[A-Za-z]+

You can test it in https://regex101.com/

@ranjani,

str = "The text is ivf road”

Try this way: str.substring(str.IndexOf("ivf ")+"ivf ".length)

@ranjani Check attached zip file Regex.zip (10.3 KB)

Thanks for the link and it worked

Thanks for the file .I had also used the same pattern

Thanks for the reply

Also i have one more o/p in below format

state =er-fd-tr-tr delay

i need text between = and space

desired o/p:er-fd-tr-tr
I used below regex which gives me o/p:=er-fd-tr-tr delay
System.Text.RegularExpressions.Regex.Match(dynamic,"=(.*)\s").Value

Use the below regex

(?<=[=])(.+?)(?=)

image

1 Like

Thank u so much

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