Regex help, please
Dave Cragg
dcragg at lacscentre.co.uk
Mon Oct 10 19:26:54 EDT 2005
On 11 Oct 2005, at 00:04, Harvey Toyama wrote:
> Hi,
>
> I have a log file to parse. The data looks like this:
>
> Chip_Test:
>
> 2 1075.7 R120<-7000h 00020000 mov
> HifRegs
> 2 1088.1 R14<-7000h 00020002 mov
> HifRegs
> 6 1100.5 [7020h]<-1h 00020004 mov
> RSTS_Busy
>
>
> I do not want to capture the line with "Chip_Test:". I know the third
> character will always be a single digit number. I have a feeble
> knowledge of Regex from casual Unix use. I thought something like this
> would work
>
> put line vLineCounter into vLineBuffer
> if char 3 of vLineBuffer = "[0-9]" then
> ...
regEx in Rev is only used in the MatchText and ReplaceText functions.
You could do this:
if char 3 of vLineBuffer is a number then
But you're missing something in the first line. Assuming vLineCounter
is a number, and the data to parse is in a variable named vData, then
you need something like this:
put line vLineCounter of vData into vLineBuffer
If you're parsing through all the lines in the file, and if it's
long, you'll find that the expression "line vLineCounter of vData"
takes longer to evaluate as the value of vLineCounter gets higher. In
that case, the "repeat for each" format would be a lot faster.
Something like:
repeat for each line vLine in vData
if char 3 of vLine is a number then
-- your stuff
end if
end repeat
Cheers
Dave
More information about the use-livecode
mailing list