RegX for specific String from TextBody

Input- By: test test test (123). Somthing
Information: 123455 test test

Output - test test test (123). Somthing

“By:” is constant need to fetch statment after that till next new line

#regex #help

Hi @Tate_S ,

Could you try using the below regex :

(?<=By:).*

Expression :

Regex.Match(yourStringVar,"(?<=By:).*").Value.Trim

image

Also, Make sure the namespace is imported :
image

HI @Tate_S

Checkout this expression

System.Text.RegularExpressions.Regex.Match(InputString,"(?<=By:\s).*").Tostring

image

Regards
Sudharsan

HI @Tate_S

You can also try with Split expression

Split(YourInputString,"By:")(1)

image

Regards
Gokul

Hi @Tate_S ,

Check this below code,
reqValue(String type) = System.Text.RegularExpressions.Regex.Match(InputString,"(?<=By:)[0-9\sA-z()].+",System.Text.RegularExpressions.RegexOptions.Multiline).Value

image

Hope this may help you :star2:

8 Likes

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