Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 正则表达式_Powershell - Fatal编程技术网

Powershell 正则表达式

Powershell 正则表达式,powershell,Powershell,我需要使用Powershell正则表达式从下面的字符串中提取一些值 Request ID = 1234 { andquot;EMOandquot;: andquot;123456-Uandquot;, andquot;Terminated Accountandquot;: andquot;Test Userandquot;, andquot;Descriptionandquot;: andquot;andquot;, andquot;Last Dayandquot;: andquot;2019-

我需要使用Powershell正则表达式从下面的字符串中提取一些值

Request ID = 1234 { andquot;EMOandquot;: andquot;123456-Uandquot;, andquot;Terminated Accountandquot;: andquot;Test Userandquot;, andquot;Descriptionandquot;: andquot;andquot;, andquot;Last Dayandquot;: andquot;2019-06-26andquot;, andquot;Terminated User Mailandquot;: andquot;Test.User@gmail.comandquot; } Location : UK ,London
我需要做个测试。User@gmail.com,测试用户和2019-06-26。请帮助我获取powershell正则表达式,以便从上述字符串获取这些值

多谢各位

我在下面试过了-

$description=Request ID=1234{andquot;EMOandquot;:andquot;123456 Uandquot;,andquot;Terminated Accountandquot;:andquot;Test Userandquot;,andquot;Descriptionandquot;:andquot;andquot;Last Dayandquot;:andquot;2019-06-26andquot;,andquot;,以及quot;Terminated User Mailandquot;:andquot;测试。User@gmail.comandquot地点:英国,伦敦

$formatdesc=$description-替换“?和”

$formatdesc 请求ID=1234{EMO:123456-U,终止帐户:测试用户,描述:,最后一天:2019-06-26,终止用户邮件:测试。User@gmail.com}地点:英国,伦敦


根据上面的内容,我将如何提取终止的用户邮件、终止的帐户和最后一天的值,这些值不是静态的,而是动态的。请提供帮助。

首先按逻辑分解您要查找的模式。看起来您正在寻找:测试。User@gmail.com测试用户-使用简单的匹配测试,例如$Myvariablename=[您的字符串]-匹配测试。User@gmail.com"


2019-06-26:对于这样一个日期,将其分解为4个数字,一个连字符,2个数字,一个连字符,然后是2个数字,这样不经过测试,很快就会得到一个匹配,比如$Myvariablename=[Your string]-match'^\d{4}-\d{2}-\d{2}'

请稍微努力一下。谢谢。尝试了以下电子邮件模式匹配,但没有帮助-[a-zA-Z0-9\-\.]+@[a-zA-Z0-9\.]+\.[a-zA-Z]{2,5}尝试过-拆分为:作为除虫剂不确定如何定位。请help@gows请更新您的答案,以包括您尝试过的所有内容:我将首先用$string-replace'?和?quot;',''之类的内容恢复引号这对于您构建所需的脚本来说已经足够了