Of course! If I am actually helping...I love regular expressions
I think the above regex will work -
PHP Code:
<?php
$myNewValue = "Something New";
$myFile = file( "myFile.txt" );
/*
myFile.txt Contains:
blahargy="http://www.google.com";
$_mls_="hiThere";
moreStuff="";
*/
foreach( $myFile as $lineNumber => $line )
echo $line."
";
$result = preg_replace('/(\\$_mls_=\\")[^"]*+(\\")/', '\\1' . $myNewValue . '\\2', $myFile );
echo "
";
foreach( $result as $lineNumber => $line )
echo $line."
";
?>
This will output:
Quote:
blahargy="http://www.google.com";
$_mls_="hiThere";
moreStuff="";
blahargy="http://www.google.com";
$_mls_="Something New";
moreStuff="";
|
The first being before the regex, and the second after...works regardless if it's empty or not!
And that regex is matching anything starting with $_mls_=", up to the second ". That could be replaced with a linefeed/carriage return by using [^\r\n]*+ instead, if there might be quotes in it.
(And that is the real output, I just tried it...

If I'm still missing something, let me know, as... I fear I am!)