-1

Hello how can i extract the date 10/3/2015 6:22:51 PM from the below expression using regex.

 disable - Olis - 10/3/2015 6:22:51 PM - est 10 -
 CN=K,CN=Users,DC=v,DC=com

Thanks

PowerShell
  • 1,821
  • 7
  • 31
  • 53
  • Possible duplicate of [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – briantist Nov 02 '15 at 16:36

1 Answers1

1

'disable - Olis - 10/3/2015 6:22:51 PM - est 10 -' -match '- (\d.*?) -'

EDIT:

You can use the $matches command to display all results - here is a really simple example:

$str = "disable - Olis - 10/3/2015 6:22:51 PM - est 10 - CN=K,CN=Users,DC=v,DC=com" 

# PATTERN:
$str -match "- (\d.*?) -"
True

# Reading data matching the pattern from string:
$matches 
Name                           Value
----                           -----
0                              10/3/2015 6:22:51 PM
$matches[0] 
10/3/2015 6:22:51 PM
Hard Tacos
  • 360
  • 1
  • 3
  • 19