Search notes:

PowerShell: the automatic variable $matches

$matches is a collection that is populated when using regular expressions with the -match and -notmatch (regexp) operator.
The type of $matches is System.Collections.Hashtable.

Simple example

'Foo 42 bar 99 baz' -match '\d+' | out-null
write-host "The matched number is $($matches[0])."
#
#  The matched number is 42. 

'Check 999 too' -notmatch '\d+' | out-null
write-host "The matched number is $($matches[0])."
#
#  The matched number is 999.
Github repository about-PowerShell, path: /language/variable/automatic/matches/simple.ps1
Note: this example does not set $matches[1].

See also

Other automatic variables

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1740453599, '18.118.20.13', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/variable/automatic/matches/index(57): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78