Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex 1

Status
Not open for further replies.

Badgers

Programmer
Nov 20, 2001
187
US
Hi

I have the following string:

'Corporate Analysis Africa February 2009'

And I want to truncate from the right so I get left with:

'Corporate Analysis Africa'

Does any one know how to write a regex statement to say truncate from the right on the 2nd space...

Thanks

Tim.
 
In regex (with some nuance chosen in the interpretation of the requirement), it can be this (in c#).
[tt]
string pattern=@"^.*?(?=\x20+[^\x20]+\x20+[^\x20]+\x20*$)";
//result is, for instance, returned by
// Regex.Matches(s,pattern)[0].ToString();
//with s the string to "match" against[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top