Regexp?

I have a file I am reading and I need to read a value, the block of text I am reading is this:

WebRefresh=1 (0 to 10 Minute(s))
AlarmResetMode=0 (0 to 1)
BatteryChemistry=0 (0 to 1)
StringSetup=1 (1 to 2), 40 (1 to 400), 1, 17.0 ( 6.5, 7.0, 8.0, 9.0,12.0,13.5,17.0)
BatteryAHCapacity=100 (100 to 2000)
BalanceBoostTime=3 (3 to 10 Second(s))
CellVoltageLimitMinMax=2.150, 2.400 (2.000 to 2.500 V)
PilotTempLimitMax=95.0 F (85.0 to 120.0 F)
AmbientTempLimitMinMax=50.0, 95.0 F (50.0 to 120.0 F)
ResponseDeviationAlarmLevel=20 (10 to 20 %)
DischargeDeviationAlarmLevel=15 (5 to 20 %)
RippleCurrentAlarmLevel=5 (0 to 2000)

now, what I do now, is look for the parameter then split it on the = sign and I need to return everything after the = sign up to the ( how would I go about this?

I am horrible with expressions.

This is what I have now that splits the = sign.

                String setLine;
                String changeValue;
                while (in.available() != 0) {
                    // Print file line to screen
                    System.out.println(""+in.readLine()+ "\n");
                    setLine = in.readLine();
                    if (setLine.indexOf("DischargeDeviationAlarmLevel") != -1) {
                        String[] line = setLine.split("=");
                        changeValue = line[1].substring(1, 2);
                        System.out.println(changeValue);
                        break;
                    }
                }

Of course code syntax suggestions always welcome as well.
LVL 2
k41d3nAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

k41d3nAuthor Commented:
And the line

 changeValue = line[1].substring(1, 2);

is actually

 changeValue = line[1];
0
CEHJCommented:
You can use this to read that file:

Properties props = new Properties();
props.load(new FileInputStream(yourFile));
String value = props.getProperty("ResponseDeviationAlarmLevel"); // gets "20 (10 to 20 %)"
0
k41d3nAuthor Commented:
I ended up using:

                String setLine;
                String changeValue;
                while (in.available() != 0) {
                    // Print file line to screen
                    System.out.println(""+in.readLine()+ "\n");
                    setLine = in.readLine();
                    if (setLine.indexOf("DischargeDeviationAlarmLevel") != -1) {
                        String[] line = setLine.split("=");
                        changeValue = line[1].substring(0, line[1].indexOf("("));
                        System.out.println(changeValue);
                        break;
                    }
                }
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

vikraman_bCommented:
hi
one example to extract the e-mail addres from a string like "dfd gfdg dgdgd hje@juf.com ejfek" using RegExp
<html>
<head>
<script>
function findEmail(str) {
    var regex=/[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]/;
    var m=str.match(regex);
    alert(m);
}
</script>
</head>
<body>

<button onclick="javascript:findEmail('the email address Myemail@hotmail.com could be anywhere');">Find the Email</button>

</body>
</html>

or

inputs.match(/(\w+)[@](\w+)[.](\w+)/g,"");


u can try the same logic for ur case
0
objectsCommented:
try something like:

                String setLine = null;
                String changeValue = null;
                while (null!=(setLine=in.readLine())) {
                    // Print file line to screen
                    System.out.println(""+setLine+ "\n");
                     if (setLine.indexOf("DischargeDeviationAlarmLevel") != -1) {
                        changeValue = setLine.split("=")[1].split(" ")[0];
//                        or perhaps depending on possible format of value
//                        changeValue = setLine.split("=")[1].split("\\(")[0];
                        System.out.println(changeValue);
                    }
                }
0
OrtokoboldCommented:
String setLine;

// pattern below: I'm not quite sure, if there has to be "\\" or just "\"
Pattern p = Pattern.compile("(\\w+)=(\\w+)\\s.*");

while ((setLine=in.readLine()) != null)
{
  // Print line to screen
  System.out.println(setLine);
  Matcher m = p.matcher(setLine);
 
  if (m.matches())
  {
    String name = m.group(1);
    String value = m.group(2);
    System.out.println("Name: " + name + " Value: " + value);
  }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.