If I have the string
thisIsSomthing=4891\r\n
thisIsSomthingElse=27398472\r\n
thisIsNumber1=1\r\n
how would I find
thisIsNumber1
and then return 1 using regex
If I have the string
thisIsSomthing=4891\r\n
thisIsSomthingElse=27398472\r\n
thisIsNumber1=1\r\n
how would I find
thisIsNumber1
and then return 1 using regex
This assumes you really have that posted content in a string, and not in a file. As you're dealing with properties, you should use Properties and not a regex:
String yourString = ...
Properties prop = new Properties();
try {
prop.load(new StringReader(yourString));
String result = prop.getProperty("thisIsNumber1");
System.out.println(result);
} catch (IOException e) {
System.out.println("Error loading properties:");
e.printStackTrace();
}
String line="thisIsNumber1=1\r\n";
String temp=line.split("\\r?\\n")[0].split("=")[1];
System.out.println("Value="+temp+"*"); // 1* "*" shows nothing is concatenated after
the character in the output
String line = "thisIsNumber1=1\r\n";