How to get the specific string between two characters from a main string

Hi Team,

I need to find the string present between two single quotes.(')
for example
-Main String:- =‘Notes except 9 and 10’!G14

Output needed- Notes except 9 and 10

2- Main String :- =’ Notes except 9 and 10’!G14

Output needed - Notes except 9 and 10

Like even the part in between single quotes start with spaces it should take that two.Like anything present in between two singles quotes (') I need to get that.

Please help

@Karan28 You can use Regex for this. Check the link :

1 Like

Hey I saw it , but it not taking the spaces in between the quotes’
=’ Karan’
I want - Karan
there are three spaces before the Karan,which means I need the exact value between the two quotes

@Karan28 Can you provide that data which you have used ?

System.Text.RegularExpressions.Regex.Match(sh,“(?<=').*(?=')”).Value.Trim

@Karan28 I meant the data not the expression :sweat_smile: What is present in sh ?

Also if you want the actual data do Not use Trim

Trim will remove spaces at the beginning and at the end

Hi , I am using this sh==’ Notes except 9 and 10’!H297

have removed the trim , still it is removing the spaces

@Karan28 Are you sure ?:sweat_smile: It should actually work, I even tested that data now.

I checked too brother

@Karan28 Can you show a Screenshot of it ?

It worked , thankyou Superman

I have created another post for changing the row length in the excel dynamically using vba.you replied on that yesterday. Please check it

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