This regex should solve your problem: /<\s*div\s+class="main-text"[^>]*>(.*?)<\/div>/gi
Here is an example in Perl:
my $str = '<div class="main-text"> and the next </div>';
$str =~ /<\s*div\s+class="main-text"[^>]*>(.*?)<\/div>/gi;
print $1;
The example is in Perl, but the regular-expression can be applied language independently.
Here is explanation of the regex:
/ -start of the regex
<\s* -we can have < and whitespace after it
div -matches "div"
\s+ -matches one or more whitespaces after the <div
class="main-text" -matches class="main-text" (so <div class="main-text" to here)
[^>]* -matches everything except >, this is because you may have more attributes of the div
> -matches >, so <div class="main-text"> until now
(.*?) -matches everything until </div> and saves it in $1
<\/div> -matches </div>, so now we have <div class="main-text">( and the next )</div> until now
/gi -makes the regex case insensitive