How can I capture groups that can change place? For example, if I have a command that contains a file name and a folder name I want a regex that can capture both the name and folder name for both of these commands:
--name "name" --folderName "folderName"
--folderName "folderName" --name "name"
I can write something like this:
"(--name (?<name>\w ) --folderName (?<folderName>\w ))|(--folderName (?<folderName>\w ) --name (?<name>\w ))"
But this is obviously very long and it would be much longer if I had more than 2 groups. I am wondering if there is a more efficient way to do this?
CodePudding user response:
Try this:"(?<=--name \")[^\"] |(?<=--folderName \")[^\"] "
Test here: https://regex101.com/r/ipMitv/1