using regex and not foreach from powershell I want to match name and get all
name ONLY in string array, the code is not working
$a=select-string -pattern "name:?(<name>))" c:\temp\main.txt| % {"$($_.matches.groups[1])"}
echo $a
$file=gc c:\temp\main.txt
$regex='name: {0}'
$file_content = [string]::Join("`r`n", $file);
Select-String -InputObject $file_content -Pattern $regex -AllMatches
---
apps:
- name: my-app
- route: dd
- main: turbo
- name: mean-app
- route: dd
- main: turbo
- name: team-app
- route: dd
- main: turbo
majorcon:
- dbcon : tr
- name: forth-app