Home > other >  Great god see the regular matching, please
Great god see the regular matching, please

Time:10-03

SQL="" "- acc_books
Insert into acc_books (id, name, db_pref, flag, type, text1, text2, text3, text4, text5, flag1, flag2, flag3, flag4, flag5, remark, data_type, book_year, book_code, area_code, split_str, storage_location, date_stamp, set_year)
Values (2690, 'total budget accounts',' 3799 _01 ', 1, 1, ' ', '1', ' 'and', ', 0, 0, 1, 1, 1, ' 'and', '2016', '371325001 _01', '371325001', '4,2,2,2,2,2,2,2,2,2,2,2,2,2', ' ', to_date (' 2015-09-24 ', 'the dd - mm yyyy hh24: mi: ss'), ");
"" "
String=sub (" (values \ [. \ n] * () (. *) (\);) "R" \ ", SQL)
2Print (string)

The above that match the values I want the content of the parentheses, so I got the three groups, the first group to values (, the second group is the content of the brackets, the third group is);

But the results are:
- acc_books
Insert into acc_books (id, name, db_pref, flag, type, text1, text2, text3, text4, text5, flag1, flag2, flag3, flag4, flag5, remark, data_type, book_year, book_code, area_code, split_str, storage_location, date_stamp, set_year)
2690, 'total budget accounts',' 3799 _01 ', 1, 1, ' ', '1', ' ' ' ', ', 0, 0, 1, 1, 1, ' 'and', '2016', '371325001 _01', '371325001', '4,2,2,2,2,2,2,2,2,2,2,2,2,2', ' ', to_date (' 2015-09-24 ', 'the dd - mm yyyy hh24: mi: ss'), ' '

CodePudding user response:

The import re
Print (re. Search (" (values \ [. \ n] * () (. *) (\);) ", SQL) group (2))

CodePudding user response:

reference 1/f, ice wind of reply:
import re
Print (re. Search (" (values \ [. \ n] * () (. *) (\);) ", SQL) group (2))

I write the regular matching no problem, why do I use the second group to replace the entire string is not about the content of the second group of
  • Related