How to remove number of character after index of 'sample1'?

“out of sample1 sdhjsdh jsbdhjgh fdjhgfjdhf jdhjfhdjhf jdkfhfjhdg fjdhfdgjhfgdhg”

Hi,

If your expected output is “out of sample1” , the following works.

System.Text.RegularExpressions.Regex.Match(yourString,".*?sample1").Value

If your expected output is “out of sample sdhjsdh jsbdhjgh fdjhgfjdhf jdhjfhdjhf jdkfhfjhdg fjdhfdgjhfgdhg” , the following will work.

System.Text.RegularExpressions.Regex.Replace(yourString,"sample\d+","sample")

Regards,

i want to remove only 23 character . how to pass length inside ?

Hi @veeraraj ,

Could you Let us know what is the Expected output for this Input String ?

If the Expected output is "out of sample1"

Try the below Expression :

str.Substring(0,str.IndexOf("sample1")+"sample1".Length)

where str is the Input String variable

The above expression gets the String from the Start of the String to the Sample1 word.

Hi,

How did you get 23?

Regards,