Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OR in regular expression?

Tags:

python

regex

I have text file with several thousands lines. I want to parse this file into database and decided to write a regexp. Here's part of file:

blablabla checked=12 unchecked=1
blablabla unchecked=13
blablabla checked=14

As a result, I would like to get something like

(12,1)
(0,13)
(14,0)

Is it possible?

like image 237
user285070 Avatar asked Nov 23 '25 14:11

user285070


1 Answers

It's simplest to use two different regexes to pull the two numbers out: r" checked=(\d+)" and r" unchecked=(\d+)".

like image 62
Marcelo Cantos Avatar answered Nov 26 '25 03:11

Marcelo Cantos