Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Numeric Data From Text String
Message
De
20/03/2013 15:50:59
 
 
À
20/03/2013 15:46:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01568867
Message ID:
01568873
Vues:
23
Sorry, I am Bit confused, can you please give me the complete code again, assuming that the File name is 123.txt



>Sir, But the text Data I have Given as Sample will be changing for each File I process than How will manage it. Can I Use FILETOSTR() in code in place of
>
>
>Changing a little bit the reg expression I showed before, as the three digits before the total were different that what you showed before (and remember to change the text endtext to filetostr:
>
>text to lcString noshow flags 1 pretext 1 + 2 + 4
>&
>Endtext
>
>
>
>
>
>
>
>
>
>
>
>>
>>local loReg, lcString, loMatches, loMatch, loSubmatch
>>
>>clear
>>
>>text to lcString noshow flags 1 pretext 1 + 2 + 4
>>w
>>G
>>195 83 89 83 L 
>>g n
>>F4 B (Branch)477 84 w
>>G
>>g n
>>F4 B (Bank)353 84 w
>>G
>>422 109 12 -9 k 
>>g n
>>F4 B (Cheque/DD)232 101 w
>>G
>>g n
>>F4 B (E-payment)440 101 w
>>G
>>g n
>>F4 B (Credit / Debit Card)327 101 w
>>G
>>g n
>>F4 B (Dated)227 84 w
>>G
>>g n
>>F4 B (Cheque/DD No.)19 84 w
>>G
>>g n
>>F4 B (Cash)157 101 y
>>G
>>g n
>>F4 B (Mode of payment)19 101 w
>>G
>>404 76 12 -9 k 
>>127 109 12 -9 k 
>>211 109 12 -9 k 
>>305 109 12 -9 k 
>>440 76 12 -9 k 
>>490 76 12 -9 k 
>>85 60 8 -8 k 
>>108 60 8 -8 k 
>>116 60 8 -8 k 
>>93 60 8 -8 k 
>>124 60 8 -8 k 
>>132 60 8 -8 k 
>>319 91 8 -8 k 
>>312 91 8 -8 k 
>>304 91 8 -8 k 
>>296 91 8 -8 k 
>>283 91 8 -8 k 
>>276 91 8 -8 k 
>>263 91 8 -8 k 
>>255 91 8 -8 k 
>>2 P 29 656 72 -43 k 
>>g n
>>F1 B (Previous Balance)65 648 y
>>G
>>g n
>>F1 B (=)487 633 y
>>G
>>g n
>>F1 B (+)206 633 y
>>G
>>121 656 72 -43 k 
>>g n
>>F1 B (Last Payment)157 648 y
>>G
>>309 655 72 -43 k 
>>g n
>>F1 B (Current Charges)346 646 y
>>G
>>g n
>>F1 B (Usage Charges)390 538 w
>>G
>>g n
>>F1 B (Tax)390 507 w
>>G
>>g n
>>F1 B (Discount)390 523 w
>>G
>>g n
>>/F5{/I 9.0 Fn2}b
>>F5 B (Summary of )392 597 w
>>F5 B (Current Charges)392 587 w
>>G
>>g n
>>F5 B (Amount \(Rs.\))561 597 x
>>G
>>g n
>>F5 B (Total Charges)393 486 w
>>G
>>0 P 24 196 13 189 L 
>>13 196 24 189 L 
>>2 P 216 656 72 -43 k 
>>g n
>>F1 B (Adjustments)252 648 y
>>G
>>0 P 100 631 28 631 L 
>>194 631 122 631 L 
>>288 631 216 631 L 
>>382 631 310 631 L 
>>572 631 500 631 L 
>>F3 (HIRA LAL GUPTA  .)31 756 w
>>(SUKH NIWAS BHOJPUR .)31 747 w
>>(SUNDERNAGAR . DISTT. MANDI \(H.P.\) .  .)31 738 w
>>(HIMACHAL PRADESH)31 729 w
>>(175002)31 720 w
>>(India)31 711 w
>>F5 (532.81)565 485 x
>>F1 (532.00)145 619 w
>>(0.00)238 619 w
>>(532.81)339 619 w
>>(0.00)564 555 x
>>(574.00)565 570 x
>>(0.00)564 538 x
>>(58.61)565 506 x
>>(531.87)42 619 w
>>g n
>>F1 B (Deposit              1200.00)31 678 w
>>G
>>g n
>>F4 B (Amex)551 68 w
>>G
>>533 76 12 -9 k 
>>g n
>>F3 Bend
>>endtext
>>
>>loReg			= CreateObject('VBScript.RegExp')
>>loReg.Pattern		= '.*(\(Total cha?r?g?e?s?\)\s?(\d+)\s)(\d+)\s?w'
>>loReg.Global		= .t.
>>loReg.IgnoreCase	= .t.
>>loMatches		= loReg.Execute(lcString)
>>if loMatches.Count > 0
>>	for each loMatch in loMatches
>>		loSubmatch	= loMatch.SubMatches.Item(2)
>>		? 'Those three unknown digits where:', loMatch.SubMatches.Item(1), 'Total charges:', loSubmatch
>>	endfor
>>else
>>	? 'No matches found'
>>endif
>>
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform