I have a program that stores the version number in a text file on the file system. I import the file within java and I am wanting to extract the version number. I'm not very good with regex so I am hoping someone can help.
The text file looks like such:
0=2.2.5 BUILD (tons of other junk here)
I am wanting to extract 2.2.5
. Nothing else. Can someone help me with the regex for this?
There are many ways to do this. Here is one of them
If you are sure that
data
contains version number then you can alsoAlso if you are really looking for a regex, though there are definitely many ways to do this.
Output:
This regular expression should do the trick:
Trying it out:
If you know the structure, you don't need a regex: