If JS had a decent regex engine, you'd just use a lookbehind instead (?<=^|;) but it doesn't so that wont work.
Next best solution is probably splitting and looping:
FoliosecCookie = getCookie('foliosec'); function getCookie( Name ) { for ( CurCookie in document.cookie.split(';') ) { var KeyValue = CurCookie.split('=',2); if ( KeyValue[0] == Name ) return KeyValue[1]; } return ''; }
You may need to use decodeURIComponent on the return value.
And for anyone wondering why the browsers don't just provide a built-in getCookie method that accepts a name and returns the value, the answer is because browser developers are fucking stupid.
/; foliosec=[a-z]+;/but I was too lazy to find out if semi-colons need to be escaped (as seems likely), didn't want to start faffing around with regex voodoo, and was tickled by the one-caricature fix (apologies to bastard for that).
And it really isn't voodoo; it's a very easy language to learn.