|
|
|||||||
I have a file that conatins data in the form <data1> (tab) <data2> (tab) <data3> The data in the middle field is IP addresses and so I cannot read the data with the substr command as they are different lengths. Is anyone aware of a way to strip the information by searching for the data between the tabs. I think the pseudocode for this would be something like $data1 = (anything from start of line to tab) $data2 = (data between tab1 + tab2) $data3 = (anything from tab2 to the end of the line) Thanks a lot Chris |
||||||||
|
|
|||||||
Try using the instr() function to search for chr(9), the tab character. I haven't tested this but try something like: code: |
||||||||
|
|
|||||||
Oops. I used $data1 as the starting point instead of evaluating it but I'm sure you get the idea. |
||||||||
|
|
|||||||
TAB is CHR(9) INSTR($text, chr(9)) will return the first occurrence of TAB in $text. If you want to remove all the TABS by converting them to space try this: piece of Swap.KiX code: $string is your text This will continue looking at string for TAB until there are none. If it finds a TAB, however, it uses the SUBSTR and INSTR functions to break the string apart and re-join it with the TAB missing and replaced with a SPACE. If you just want to strip out the TABs, make $changeto="" If you want to separate the pieces out without the TABs, you have two choices. 1. Use the SPLIT function in the new KiXtart 2001 Beta. 2. Use cjs VBSplit.KiX script that works in KiXtart 3.6x and does the same as the new KiX2k function. You can get VBSplit.KiX from here
|
||||||||
|
|
|||||||
Hiya Chris, i can't resist to post my result (costs that much time !) alltough that vbsplit might be much better .. so here's my sample text input : code: and here comes the script : code:
[This message has been edited by jpols (edited 17 April 2001).] |
||||||||
|
|
|||||||
... or much better , make the array independant from the number of Lines : code:
[This message has been edited by jpols (edited 18 April 2001).] |