Q:

JavaScript: Regex to get string between ";;;"

I have seen couple  similar post related my question, but I'm unable to get my Regex right.
how to get string in between ";;;" as shown below
;;; My Result ;;; --> My Result
;;; Title:Learning Regex ;;; --> Title:Learning Regex
;;; with all special characters !@#$%^&*()';" ;;; --> with all special characters !@#$%^&*()';"
;;; this should return nothing --> ""

tried below solution but no luck
 var str = ';;; Title:Learning Regex ;;;';
 var res= str.match(/^;{3}\w;{3}$/).pop();

any JavaScript Regex Guru, please help.

A:

The biggest problem with this task is that you might want to differentiate between non-three semi-colon delimiters. 
I'd suggest
^;{3}(?!;)([\s\S]*?[^;]);{3}$

For standalone strings use a version with greedy quantifier:
^;{3}(?!;)([\s\S]*[^;]);{3}$
                 ^

See demo
Explanation:

^ - start of string
;{3} - 3 semi-colons
(?!;) - fail a match if the next character is a ;
([\s\S]*?[^;]) - match zero or more characters (incl. a newline) up to the last 3 semi-colons, and the 4th character from the end cannot be a ; (NOTE: when using with standalone strings, replace [\s\S]*? with [\s\S]*,a greedy version!)
;{3} - 3 semi-colons
$ - end of string

