lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

2 questions related to the same kind of strings :

1/ I have a string like this one :
l="Débit ATM              3939 kb/s          945 kb/s"

How can I extract only numbers ?
If I do
    print( l:match('(%d+)(%d+)' ))
I got only :
    393    9

'9' being the last digit of 3939.

2/ If I want to generalize, I got a set of strings link

  Débit ATM              3939 kb/s          945 kb/s         
  Marge de bruit         8.10 dB            8.20 dB          
  Atténuation            56.00 dB           33.40 dB         
  FEC                    21976              196              
  CRC                    600                0                
  HEC                    38                 184              

I would like to retrieve :
lab : the line label ('Débit ATM' or 'Marge de bruit', ...)
val1 : first value
val2 : second value.

I played a long time with patterns without luck, so ...

Thanks

Laurent