Given:
PS D:\tmp> cat .\1.txt
<abc xyz="1"
def="xx">
xaxa
</abc>
<abc xyz="a">
PS D:\tmp>
What I was trying:
PS D:\tmp> cat .\1.txt | sls '(?m:)<abc[^>]+>'
<abc xyz="a">
PS D:\tmp> cat .\1.txt | sls '(?m:)<abc(?:[^>]|$)+>'
<abc xyz="a">
PS D:\tmp> cat .\1.txt | sls '(?m:)<abc(?:[^>]|\$)+>'
<abc xyz="a">
PS D:\tmp>
Now I know all the three variants work as expected in plain C#. For example:
PS D:\tmp> [Text.RegularExpressions.Regex]::Matches($(cat 1.txt), '(?m:)<abc[^>]+>')
Groups : {<abc xyz="1" def="xx">}
Success : True
Captures : {<abc xyz="1" def="xx">}
Index : 0
Length : 27
Value : <abc xyz="1" def="xx">
Groups : {<abc xyz="a">}
Success : True
Captures : {<abc xyz="a">}
Index : 42
Length : 13
Value : <abc xyz="a">
PS D:\tmp>
So, I am curious - what am I doing wrong in pure Powershell that it does not work?