Re: more python3 regex?

2016-09-11 Thread Doug OLeary
Hey, all; The print suggestion was the key clue. Turned out my loop was slurping the whole of data in one big line. Searching for a line that begins with Name when it's in the middle of the string is... obviously not going to work so well. Took me a bit to get that working and, once I did, I

Re: more python3 regex?

2016-09-11 Thread Lawrence D’Oliveiro
On Monday, September 12, 2016 at 6:21:57 AM UTC+12, Peter Otten wrote: > By the way, many simple text-processing problems can be solved without > regular expressions. The old JWZ quote instantly comes to mind... -- https://mail.python.org/mailman/listinfo/python-list

Re: more python3 regex?

2016-09-11 Thread Peter Otten
Doug OLeary wrote: > Hey > > This one seems like it should be easy but I'm not getting the expected > results. > > I have a chunk of data over which I can iterate line by line and print out > the expected results: > > for l in q.findall(data): > # if re.match(r'(Name|")', l): > #

more python3 regex?

2016-09-11 Thread Doug OLeary
Hey This one seems like it should be easy but I'm not getting the expected results. I have a chunk of data over which I can iterate line by line and print out the expected results: for l in q.findall(data): # if re.match(r'(Name|")', l): # continue print(l) $ ./testies.py | wc -l

Re: python3 regex?

2016-09-10 Thread Doug OLeary
Hey, all; thanks for the replies - reading data in one slurp vs line by line was the issue. In my perl programs, when reading files, I generally do it all in one swell foop and will probably end up doing so again in this case due to the layout of the text; but, that's my issue. Thanks again.

Re: python3 regex?

2016-09-10 Thread breamoreboy
On Saturday, September 10, 2016 at 4:12:17 AM UTC+1, Doug OLeary wrote: > Hey; > > Long term perl ahderent finally making the leap to python. From my reading, > python, for the most part, uses perl regex.. except, I can't seem to make it > work... > > I have a txt file from which I can grab

Re: python3 regex?

2016-09-10 Thread Jussi Piitulainen
Jussi Piitulainen writes: > dkole...@olearycomputers.com writes: >> [- -] > import re > p = re.compile('"?[1-9]*\.') That should be a raw string: r'"?[1-9]*\.' Sorry about that. I wish Python would complain. -- https://mail.python.org/mailman/listinfo/python-list

Re: python3 regex?

2016-09-10 Thread Jussi Piitulainen
dkole...@olearycomputers.com writes: > Hey; > > Long term perl ahderent finally making the leap to python. From my > reading, python, for the most part, uses perl regex.. except, I can't > seem to make it work... > > I have a txt file from which I can grab specific titles via a perl > one-liner:

Re: python3 regex?

2016-09-09 Thread Christian Gollwitzer
Am 10.09.16 um 05:12 schrieb dkole...@olearycomputers.com: Hey; Long term perl ahderent finally making the leap to python. From my reading, python, for the most part, uses perl regex.. except, I can't seem to make it work... I have a txt file from which I can grab specific titles via a perl

Re: python3 regex?

2016-09-09 Thread Lawrence D’Oliveiro
On Saturday, September 10, 2016 at 3:12:17 PM UTC+12, Doug OLeary wrote: > $ perl -ne 'print if (m{^("?)[1-9]*\.})' tables Perl has this feature of being able to use alternate delimiter symbols for the pattern; Python does not. > >>> regex = r'^("?)[1-9]*\.' Try putting a backslash in front of

python3 regex?

2016-09-09 Thread dkoleary
Hey; Long term perl ahderent finally making the leap to python. From my reading, python, for the most part, uses perl regex.. except, I can't seem to make it work... I have a txt file from which I can grab specific titles via a perl one-liner: $ perl -ne 'print if (m{^("?)[1-9]*\.})' tables