01-17-2011 04:28 AM
I'm trying to search a particular value in a string file. The string contains many parameters followed by their values and units. I want to identify and extract, as a number, the value of a particular parameter. The program will basically ask the user to type in (or select from a list of given) parameters in a dialogue box. Then it should display the value of the parameter.
The string I'm trying to work with, is of the form:-
SensorOneInMM,34585
BatteryVoltageInmV,19761
BattTemp1InC,20
CliffDistanceLeftInMM,60
CliffDistanceRightInMM,60
RightSensor,0
LeftSensor,0
CurrentInmAforMotor, 789
TestingCurrentInmA, 123
Temp1InC,28
Temp2InC,28
BaseCurrentInmA,1342
ChargeInmV,218
CurrentInmA,9999
NotConnected3,0
Now, for example the value I want to read is the one in Blue color. But the expression, "CurrentInmA" appears several times, in the string. How can I identify the value of the parameter in Blue color??
Thanks for helping out an amateur!!!
Cheers.
01-17-2011 05:29 AM
Hi RAJ,
There are plenty of ways to do what you are after, here is just one:
Im sure there are better ways though,
Rgs,
Lucither.
01-17-2011 06:29 AM
This will also do the job:
MC
01-17-2011 07:08 AM
01-17-2011 01:49 PM
I like to use Match Regular Expression.
^ locks the match to the begining of a line.
(\d+) will return just the digits out the submatch. Expand the Match Regular Exptession down to add submatch output.
01-17-2011 04:23 PM