regex
plug-in only returns one matched value after regular expression matches.
#85
Labels
regex
plug-in only returns one matched value after regular expression matches.
#85
Description of the Error
While using
regex
plug-in to extract part of instance type parameter value, only a single matched value is returned from matches.Expected Behaviour
Given this input string "Standard_DS2_v1" and the regular expression "/(?<=)[^_]+?(?=|$)/g", I wanted it to return "DS2 v1" of the 2 matched elements with a space in between.
Actual Behaviour
The return result is only "DS2" , first matched element but without the second matched element "v1" in the total result.
Steps to Reproduce
Run
regex
plug-in using IF manifest (output section shown below):Link to online environment
Used https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#try_it to try out the same string and regex inputs, since the plug-in typescript leverages the standard String prototype match() method.
Looking at https://github.com/Green-Software-Foundation/if-plugins/blob/main/src/lib/regex/index.ts, it returns only the 1st array object in
extractMatching
block, which is incorrect.Additional qns: if the entire array is returned, how can we concatenate the elements together or can
regex
do that for us, with space between the elements?Manifest File That Generated the Error
Links to Any Additional Code
NA
Runtime Info
Running on local laptop:
Windows OS 10
IF version:
The text was updated successfully, but these errors were encountered: