Caravan Business Server>Help>Parser>Text |
Syntax
|
var <output variable>={<text>}X{<criteria>}:{<value1,value2,value3>} Where output variable is the variable where the values should be stored after parsing the text.Criteria specifies the criteria in which the parsing has to be done.value1,value2,etc specifies the variables where the result of the parsing to be stored.
|
Text
|
Many times you may need to parse text from a file or a variable to extract some information. You can extract information from a file meeting specified criteria by reading each line in the file. Caravan provides a powerful object to parse text in many ways.
|
Sample
|
The syntax may look complex but if you look at the few examples given below you will realize that it is not so complex as you thought.
Parsing a variable. <caravan> var temp temp(email)=manoj_kg@hotmail.com //extract the email id and domainseparately var res={temp(email)}X{`*`@`*`}:{id,domain} if res(id) "User id is :";res(id);"<br>" "Domain is :";res(domain);"<br>" endif </caravan>
Parsing a text file. <caravan> //open a file file f=c:\\windows\\win.ini //read each line and display loop ctr (1000) //read each line and display the sections in win.ini var res={f(nextline)}X{[‘*`]}:{myline} if res res(myline); endif repeat ctr 1000 </caravan>
Parsing a specific value. <caravan> var temp temp(ordernumber)=SBQ:123458 //separate the alphabetical part and numerical part var res={temp(ordernumber)}X{[‘&&&`:‘######`]}:{ordalpha,ordnum} if res //alphabetical part res(ordalpha);"<br>" //numerical part of the order number res(ordnum);"<br>" endif </caravan>
|
Back
|