need to check the version value in text file using vbscript

414 views Asked by At

I have a text file and just need to check version value mentioned in that text file. I have to grep version value (0.0.1) and check that value in VBScript If condition. If version is increased (0.0.2), next time script will need to check the new version. I usually do it in shell script, but I don't know how to do it in windows VBScript.

{
  "name": "iap",
  "version": "0.0.1",
  "ignore": [
    "poc"
  ],
  "devDependencies": {
    "angular": "~1.2",
    "oclazyload": "~0.3",
  }
1

There are 1 answers

3
Ansgar Wiechers On BEST ANSWER

You could use a regular expression to match that particular line and extract the version information:

line = ...

Set re = New RegExp
re.Pattern = """version"": ""(\d+\.\d+\.\d+)"""

Set m = re.Execute(line)
If m.Count = 1 Then
  version = m(0).SubMatches(0)
End If

WScript.Echo version