簡體   English   中英

使用正則表達式powershell提取“-”之間的字符集

[英]Extract set of characters between "-" using regex powershell

您好,我如何使用正則表達式從以下表達式中提取日期 10/3/2015 6:22:51 PM。

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

謝謝

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

編輯:

您可以使用$matches命令顯示所有結果 - 這是一個非常簡單的示例:

$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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM