If i have a line that ends like
version is: 1.10.0.1001
i'm looking for a regex to get the version number but can't figure out how to get the string following "version is:"
Use parantheses to capture values. If you only want the entire version value in one string, this would be enough
if(/version is:(.*)/.test(yourString)) {
versionNum = RegExp.$1;
}
Here versionNum will store 1.10.0.1001.
But if you wanted the individual numbers between the dots, you would have to go with something like this:
if(/version is:(\d+\.)(\d+\.)(\d+.)(\d+)/.test(yourString)) {
majorBuild = RegExp.$1;
minorBuild = RegExp.$2;
patch = RegExp.$3;
revision = RegExp.$4;
}
Basically the variables will hold values like this
majorBuild = 1
minorBuild = 10
patch = 0
revision = 1001
Cheers!
use a capture (parentheses). Try
s/version is:(.*)/\1/g
also, what regex engine are you using? You may need to escape the colon, and determine if magic is on/off
or better yet, just remove version is: and everything before it
s/.*version is://g
:and consider the rest.