I am new to Java. Please help me with a Java regex to match a pattern and retrieve the value.
I need to match the pattern bellow:
\# someproperty=somevalue // this is a new property
\#someproperty=somevalue // this is a new property
I have to match the above patterns (which may contains spaces) and I need to retrieve "someproperty" and "somevalue".
I tried with the pattern below, but it just matches only someproperty=somevalue , without "#" at the beginning. Please help me out.
Pattern propertyKeyPattern = Pattern.compile("^\\s*(\\S+?)\\s*=.*?");
If you want to match the whole string and find patterns, such as “
\# someproperty =some value“.Try regular Expression
as Java string, it is
The match result for string
\# someproperty = a some valueis