How to extract a string from start till specific character

Hi , I have a string

string:- schedule!E26

I need to have a string from start till ! which means - schedule

1 Like

You can use something called substring along with getting the index of !

I have given 2 options below:

StringVar.Substring(StringVar.IndexOf("!")).ToString =!E26

StringVar.Substring(StringVar.IndexOf("!")+1).ToString = E26

1 Like

Hi,

Hope the following helps you.

text.Split({"!"c})(0)

OR

System.Text.RegularExpressions.Regex.Match(text,"^.*?(?=!)").Value

Regards,

3 Likes

Hi @Karan28

Can be also done by following way :-

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

6 Likes

Thankyou so much everyone for the solution. I dont know whom solution to mark as solution

use regex pattern .*(?=!)

1 Like

Hi @Karan28

Heh heh heh :sweat_smile:

The one you feel more efficient n suitable for your query mark it as a solution.

As marking as a solution helps other candidate while searching.
If some is facing same issue and want the solution so that person will directly gets directed to the exact solution that helps you to solve the same query.

So for that mark as a solution the one you feel that it as more efficient.

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

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