I want to extract the content between abc { and }.
$s = 'abc {
123
}'
$s -match 'abc {(.*?)' # true
$s -match 'abc {(.*?)}' # false, expect true
However, it seems it doesn't do multiple line match?
I want to extract the content between abc { and }.
$s = 'abc {
123
}'
$s -match 'abc {(.*?)' # true
$s -match 'abc {(.*?)}' # false, expect true
However, it seems it doesn't do multiple line match?
. will only match on newline characters when you perform a regex operation in SingleLine mode.
You can add a regex option at the start of your pattern with (?[optionflags]):
$s -match 'abc {(.*?)}' # $False, `.` doesn't match on newline
$s -match '(?s)abc {(.*?)}' # $True, (?s) makes `.` match on newline