You could do it the dirty way, by using
string functions such as String.indexOf and String.substr:
code:
//This is a sample string, you'll probably want to get this string through some code...
var strTitle = "Start Page - Microsoft Visual Basic 2008 Express Edition";
//Try to find the last occurrence of the title suffix
var pos = strTitle.lastIndexOf(" - Microsoft Visual Basic 2008 Express Edition");
if(pos !== -1) {
//Found it, now cut the wanted part from the string
var strTitleName = str.substr(0, pos);
} else {
//Not found, some error handling here?
}
A bit more advanced method, but much shorter and cleaner, is to use
regular expressions:
code:
var strTitle = "Start Page - Microsoft Visual Basic 2008 Express Edition";
//Make a RegExp object - check out the link for an explanation of the used special characters.
var reSuffix = new RegExp("^(.+) \\- Microsoft Visual Basic 2008 Express Edition$", "i");
//Test the string with the RegExp
if(reSuffix.test(strTitle)) {
//Got a match, the name is now in $1
var strTitleName = RegExp.$1;
} else {
//No match, some error handling here?
}