Python regular matching
how do you use Python to match the two parameter values in SetValue in the following string?
for example, several pieces of data failed to match between "Att_Sys_zh-cn_11_G" and"12 12 5"
.
<script>
function init(){
SetValue("txt_gtin","<img src =http://219.232.114.116:8080/barcode4j/gensvg?type=ean13&msg=6926533332590&fmt=png&hrsize=5pt&hrfont=song&qz=0.2cm&wf=1&mw=0.17mm&height=1cm />");
SetValue("Att_Sys_zh-cn_11_G","12*12*5");
SetValue("Att_Sys_zh-cn_117_G","2017-09-10");
SetValue("Att_Sys_en-us_141_G","kaig");
SetValue("Att_Sys_zh-cn_171_G","");
SetValue("Att_Sys_zh-cn_181_G",",");
SetValue("Att_Sys_zh-cn_332_G","-");
SetValue("Att_Sys_zh-cn_304_G","RISYM/") ;
SetValue("Att_Sys_zh-cn_141_G","12*12*5") ;
SetValue("Att_Sys_zh-cn_22_G","39121532(>>>>>>)");
SetValue("Att_Sys_zh-cn_107_G","");
SetValue("Att_Sys_zh-cn_107_G","");
SetValue("Att_Sys_zh-cn_107_G","");
SetValue("Att_Sys_zh-cn_74_G","");
delNullRow();}
</script>
SetValue\('([^']*)','([^']*)'\)
take grouping 1 and grouping 2
SetValue('Att_Sys_zh-cn_304_G','RISYM/') ;
SetValue('Att_Sys_zh-cn_141_G','12*12*5') ;
there is a space before the semicolon at the end of these two paragraphs. You can use replace (',') to remove the extra spaces, and then you can match properly.
temp_str = """
<script>
function init(){
SetValue('txt_gtin','<img src =http://219.232.114.116:8080/barcode4j/gensvg?type=ean13&msg=6926533332590&fmt=png&hrsize=5pt&hrfont=song&qz=0.2cm&wf=1&mw=0.17mm&height=1cm />');
SetValue('Att_Sys_zh-cn_11_G','12*12*5');
SetValue('Att_Sys_zh-cn_117_G','2017-09-10');
SetValue('Att_Sys_en-us_141_G','kaig');
SetValue('Att_Sys_zh-cn_171_G','');
SetValue('Att_Sys_zh-cn_181_G',',');
SetValue('Att_Sys_zh-cn_332_G','-');
SetValue('Att_Sys_zh-cn_304_G','RISYM/') ;
SetValue('Att_Sys_zh-cn_141_G','12*12*5') ;
SetValue('Att_Sys_zh-cn_22_G','39121532(>>>>>>)');
SetValue('Att_Sys_zh-cn_107_G','');
SetValue('Att_Sys_zh-cn_107_G','');
SetValue('Att_Sys_zh-cn_107_G','');
SetValue('Att_Sys_zh-cn_74_G','');
delNullRow();}
</script>
"""
res = re.findall(r"SetValue\(\'(.*?)\',\'(.*?)\'", temp_str)
print(res)
-sharp
[('txt_gtin', '<img src =http://219.232.114.116:8080/barcode4j/gensvg?type=ean13&msg=6926533332590&fmt=png&hrsize=5pt&hrfont=song&qz=0.2cm&wf=1&mw=0.17mm&height=1cm />'), ('Att_Sys_zh-cn_11_G', '12*12*5'), ('Att_Sys_zh-cn_117_G', '2017-09-10'), ('Att_Sys_en-us_141_G', 'kaig'), ('Att_Sys_zh-cn_171_G', ''), ('Att_Sys_zh-cn_181_G', ','), ('Att_Sys_zh-cn_332_G', '-'), ('Att_Sys_zh-cn_304_G', 'RISYM/'), ('Att_Sys_zh-cn_141_G', '12*12*5'), ('Att_Sys_zh-cn_22_G', '39121532(>>>>>>)'), ('Att_Sys_zh-cn_107_G', ''), ('Att_Sys_zh-cn_107_G', ''), ('Att_Sys_zh-cn_107_G', ''), ('Att_Sys_zh-cn_74_G', '')]