Link to home
Start Free TrialLog in
Avatar of Peter Nordberg
Peter NordbergFlag for Sweden

asked on

TrimEnd

Hi,

I have this string:
SELECT * FROM image_descr WHERE keywords LIKE '% linda%' AND keywords LIKE '%2007%' AND keywords LIKE '%

I would like to trim the end so that the last part gets trimmed away:
AND keywords LIKE '%

I've tried the following:
Dim strParse As String = strSearch.TrimEnd("%", "'", "LIKE", "keywords", "AND")

Unforunately it only trims the last part like this:
SELECT * FROM image_descr WHERE keywords LIKE '% linda%' AND keywords LIKE '%2007%' AND keywords LIKE

How can I get it to trim away the rest?

Thanks for help!

Peter
Avatar of Type25
Type25

string s = @"SELECT * FROM image_descr WHERE keywords LIKE '% linda%' AND keywords LIKE '%2007%' AND keywords LIKE '%";

            int i = s.LastIndexOf("AND");
            string x = s.Substring(0, i);

            MessageBox.Show(x);
ASKER CERTIFIED SOLUTION
Avatar of Ashley Bryant
Ashley Bryant
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Nordberg

ASKER

Thanks! Both scripts did what I wanted!

Peter