regex - How can we replace multiple match with only one word/phrase replace using powershell -
how can replace multiple match 1 word/phrase replace using powershell
below matches in regex
grant access server1
grant access server2
grant access server3
grant access server4
need replace results above 1 phrase below,
word of day!
i not entirely sure op going looking match lines following
grant access server1 grant access server2 grant access server3 grant access server4 you can use pattern (grant access server\d+(\n)?){4}. match raw text "grant access server" followed @ least 1 digit. in event last item @ end of string (last item wont have newline) include optional (\n)? newline. @ end quatifier of {4} since example had 4 occurances. replace {4} * greedy capture of occurances in sequence.
so (grant access server\d+(\n)?)* match:
grant access server1 grant access server3 grant access server44325 grant access server4 grant access server44 grant access server3
Comments
Post a Comment