Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: how to deal with newline

by Laurent_R (Canon)
on Oct 27, 2013 at 16:55 UTC ( #1059923=note: print w/replies, xml ) Need Help??

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"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="Dylan

You 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).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059923]
[nettop]: need to hire a PERL programmer
[shmem]: conditions?
[shmem]: tell them

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-04-20 17:23 GMT
Find Nodes?
    Voting Booth?