PowerShell 5.1
How do I get the date out of this string? Are those delimiters pretty good to use?
'blah blah ???5/28/24 15:55??? blah blah blah' -match '???.*\s.*???'
$Matches
I was hoping this would do it:
-match '???.*\s.*???'
>Solution :
You need to escape the ? as it is a special regex character (quantifier), what I imagine you wanted was \?\?\?.*\s.*\?\?\? or simplified \?{3}.*\s.*\?{3} and if you wanted to capture what is in between the ??? then you would need a capturing group, so:
'blah blah ???5/28/24 15:55??? blah blah blah' -match '\?{3}(.*\s.*)\?{3}'
$Matches[1] # => 5/28/24 15:55
See https://regex101.com/r/0DgImA/1 for regex details.
Another option that might work for your use case is using a lookbehind assertion:
'blah blah ???5/28/24 15:55??? blah blah blah' -match '(?<=\?{3})[^?]+'
$Matches[0] # => 5/28/24 15:55
See https://regex101.com/r/n7g4qP/1 for regex details.