Re: Regex: Perl to Python

2016-03-07 Thread Fillmore
Big thank you to everyone who offered their help! On 03/06/2016 11:38 PM, Fillmore wrote: -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex: Perl to Python

2016-03-06 Thread Peter Otten
Fillmore wrote: > > Hi, I'm trying to move away from Perl and go to Python. > Regex seems to bethe hardest challenge so far. > > Perl: > > while () { > if (/(\d+)\t(.+)$/) { > print $1." - ". $2."\n"; > } > } > > into python > > pattern = re.compile(r"(\d+)\t(.+)$") > with open(fiel

Re: Regex: Perl to Python

2016-03-06 Thread Rustom Mody
Also for regex hacking: Try with findall before using match/search -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex: Perl to Python

2016-03-06 Thread Rustom Mody
Also for regex hacking: Try with findall before using match/search -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex: Perl to Python

2016-03-06 Thread Terry Reedy
On 3/6/2016 11:38 PM, Fillmore wrote: Hi, I'm trying to move away from Perl and go to Python. Regex seems to bethe hardest challenge so far. Perl: while () { if (/(\d+)\t(.+)$/) { print $1." - ". $2."\n"; } } into python pattern = re.compile(r"(\d+)\t(.+)$") with open(fields_I

Re: Regex: Perl to Python

2016-03-06 Thread Chris Angelico
On Mon, Mar 7, 2016 at 3:38 PM, Fillmore wrote: > pattern = re.compile(r"(\d+)\t(.+)$") > with open(fields_Indexfile,mode="rt",encoding='utf-8') as headerfile: > for line in headerfile: > #sys.stdout.write(line) > m = pattern.match(line) > print(m.group(0)) > header