Search code examples
regexjenkinsstring-parsingveracode

How to extract only numbers inside of double quotes with regex


useragent "VeracodeJenkinsPlugin/18.11.5.8 (Jenkins/2.150.3; Java/1.8.0_181)"
16:02:43.582  [19.07.18 14:02:43] 
16:02:43.582  [19.07.18 14:02:43] Application profile "Cleared Derivatives Solution" (appid=74386) was located.
16:02:43.582  [19.07.18 14:02:43] 
16:02:43.582  [19.07.18 14:02:43] Attempting to create a new build with name "veracode_scan_2019.7.0_1".
16:02:45.844  [19.07.18 14:02:45] 
16:02:45.844  [19.07.18 14:02:45] The build_id of the new build is "4538017".
16:02:45.845  [19.07.18 14:02:45] 
16:02:45.845  [19.07.18 14:02:45] Uploading: /somepath/nodecontrolleripp.jar
16:02:48.433  [19.07.18 14:02:48] 
16:02:48.433  [19.07.18 14:02:48] Starting pre-scan verification for application "Cleared Derivatives Solution" build "veracode_scan_2019.7.0_1".
[Pipeline] }
[Pipeline] // withCredentials

Hi, in this case i just want to get numbers like 4538017 without double quotes for build_id so i can store it in variable and use it later on. Tried many solutions from internet, using: https://regexr.com/ but none worked out, i'm constantly receiving double quotes and number inside.


Solution

  • You need to use zero-width assertions for the quotes, /(?<=")\d+(?=")/g

    see: https://regexr.com/4hpek