I do not know if there is any lib specially designed to process the
strings in scipt language.
for example:
I hope to process the string"print a,b,c,d,e "in the form"command
argumentlist" and return:
{'command'='pri nt',
'argumentlist'=['a','b','c','d' ,'e']}
Are there any lib to implement this?
Ideally , the lib should have a function like below:
def extract(command string, splitformat)
eg:
extract("see#yo u@tonight","wha t#whom@when")
return: {"what":"see"," whom":"you","wh en":"tonight" }
extract("1;2;3; 4;5","list[;]")
return: {"list":['1','2','3','4' ,'5']}
extract("print a,b,c,d,e","com mand arglist[,]")
return: {"command":"pri nt","arglist" :['a','b','c','d' ,'e']}
extract("fruit: apple~orgrange~ pear~grape#name :tom;sam;dim;ha m"
,"class1:instan ce1[~]#class2:instanc e2[;]")
return: {"class1":"frui t",
instance1:['apple','orange ','pear','grape '],
"class2":"name" ,
"instance2" :['tom','sam','di m','ham']
}
####### # # # #
# # # # #
# # # # #
# ####### #
# # # # #
# # # # #
# # # # #
strings in scipt language.
for example:
I hope to process the string"print a,b,c,d,e "in the form"command
argumentlist" and return:
{'command'='pri nt',
'argumentlist'=['a','b','c','d' ,'e']}
Are there any lib to implement this?
Ideally , the lib should have a function like below:
def extract(command string, splitformat)
eg:
extract("see#yo u@tonight","wha t#whom@when")
return: {"what":"see"," whom":"you","wh en":"tonight" }
extract("1;2;3; 4;5","list[;]")
return: {"list":['1','2','3','4' ,'5']}
extract("print a,b,c,d,e","com mand arglist[,]")
return: {"command":"pri nt","arglist" :['a','b','c','d' ,'e']}
extract("fruit: apple~orgrange~ pear~grape#name :tom;sam;dim;ha m"
,"class1:instan ce1[~]#class2:instanc e2[;]")
return: {"class1":"frui t",
instance1:['apple','orange ','pear','grape '],
"class2":"name" ,
"instance2" :['tom','sam','di m','ham']
}
####### # # # #
# # # # #
# # # # #
# ####### #
# # # # #
# # # # #
# # # # #
Comment