[Gambas-user] gb.pcre help anyone?

Ron ron at ...1740...
Wed Jul 23 22:04:13 CEST 2008


Benoit Minisini schreef:
> On mercredi 23 juillet 2008, Ron wrote:
>   
>> Hi,
>>
>> In my quest to parse a string to get some values from it, I ended up
>> with way to much string functions.
>>
>> So I want to parse it a bit more efficient with gb.pcre... so far so
>> good, but I 'm stumped as how to use it.
>> Very sparse docs found on gambasdoc.org, but can anybody give an example?
>>
>> Let say I have this:
>> Temp #01[4D0000004FC78A26]=24.31C
>>
>> And want to get the address (between the brackets) and the temp with the
>> use of gb.pcre...
>>
>> Maybe a competition; who can get those values with the least amount of
>> Gambas code...? ;-)
>>
>> Regards,
>> Ron_2nd
>>
>>     
>
> You don't need gb.pcre for simple extraction. You can use the built-in Scan() 
> function:
>
> DIM sStr AS String = "Temp #01[4D0000004FC78A26]=24.31C"
> DIM aScan AS String[]
> aScan = Scan(sStr, "*[[]*]=*")
> PRINT "Address: "; aScan[1]
> PRINT "Temp: "; aScan[2]
>   

Ok! even better, you are right...

I love Gambas more and more!

Thanks,
Ron_2nd






More information about the User mailing list