Hi Sach!
if the line you're interested in starts with "login = "
I'd just search for that and when it's found write out the
newly assembled line:
String accountInfo = "login=" + login + " " + password
. That should do the trick.
Now I've got it:
searchFor = "(\\s+login\\s*=\\s*)(.+)(\\r\\n)";
replaceWith = "$1" + userName + " " + password + "$3");
contents = "# This is a test\r\n" +
"login = Will be replaced\r\n" +
"# more test lines\r\n" +
"login2 = Wont be touched\r\n"
"# more test\r\n";
The $1 and $3 part of the replace expression correspond to the first and the third group.
Cheers
Manfred