in reply to how to deal with newline
Besides the line by line issue already identified, one of the problems with your regex is greedy match. If your line contains something like this:
'some random text..name="Bob"..some more random text surname="Dylan" some more text'the name=\"(.*)\" part of your regex will match as much as it can between quotes, i.e.:
Bob"..some more random text surname="DylanYou have to either make your * quantifier non greedy by adding the ? qualifier, name=\"(.+?)\", or match characters which are anything but quotes, name=\"([^"]+)\" (I also changed * to + because it does not seem to make too much sense to match an empty string between quotes).
|
|---|