Powershell Regex antisèche
Une collection de le regex qui je recherche souvent.
#Trouve le groupe avec un nom
'LesColourDesVache Brun' -match '(?<Attribut>\w+) (?<Valeur>\w+)' | out-null
$matches.Attribut
$matches.Valeur
#LesColourDesVache
#Brun
#Remplacer pour reformater un string
"J'ai un grande problem" -replace '.* (g[^ ]+).*',"C'est pas trop `$1"
#C'est pas trop grande
#appariement paresseux (pour previnir appariement exessif) utilise un ? apres la + ou *
"<h1>MyHeading</h1>" -replace '<([^/]+?)>','<cow>' -replace '</([^/]+?)>','</cow>'
#<cow>MyHeading</cow>