fybhwsx 发表于 2020-1-25 22:03:44

求个正则提取某一段中的日期【已解决】感谢 floor6ggg

本帖最后由 fybhwsx 于 2020-1-25 23:10 编辑

提取<!-- \Microsoft\Windows\Flighting\OneSettings\RefreshCache -->这一段下面<StartBoundary>后面的2020-01-26
还有<!-- \Microsoft\Windows\PushToInstall\Registration -->这段下面<StartBoundary>后面的2020-01-25



<!-- \Microsoft\Windows\Flighting\OneSettings\RefreshCache -->
<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

<RegistrationInfo>

    <SecurityDescriptor>D:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FRFX;;;AU)</SecurityDescriptor>

    <Source>$(@%systemroot%\system32\wosc.dll,-602)</Source>

    <Author>$(@%systemroot%\system32\wosc.dll,-601)</Author>

    <Description>$(@%systemroot%\system32\wosc.dll,-603)</Description>

    <URI>\Microsoft\Windows\Flighting\OneSettings\RefreshCache</URI>

</RegistrationInfo>

<Principals>

    <Principal id="LocalSystem">

      <UserId>S-1-5-18</UserId>

    </Principal>

</Principals>

<Settings>

    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>

    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

    <ExecutionTimeLimit>PT5M</ExecutionTimeLimit>

    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>

    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>

    <IdleSettings>

      <StopOnIdleEnd>false</StopOnIdleEnd>

      <RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>

</Settings>

<Triggers>

    <TimeTrigger>

      <StartBoundary>2020-01-26T21:10:22+08:00</StartBoundary>

      <Repetition>

      <Interval>PT3H23M</Interval>

      </Repetition>

      <RandomDelay>PT1H</RandomDelay>

    </TimeTrigger>

    <WnfStateChangeTrigger>

      <StateName>7538BCA33A019502</StateName>

    </WnfStateChangeTrigger>

</Triggers>

<Actions Context="LocalSystem">

    <ComHandler>

      <ClassId>{E07647F7-AED2-48D9-9720-939BC24A8A3C}</ClassId>

    </ComHandler>

</Actions>

</Task>



<!-- \Microsoft\Windows\HelloFace\FODCleanupTask -->
<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

<RegistrationInfo>

    <SecurityDescriptor>D:P(A;;FA;;;BA)(A;;FA;;;SY)(A;;FA;;;NU)</SecurityDescriptor>

    <URI>\Microsoft\Windows\HelloFace\FODCleanupTask</URI>

</RegistrationInfo>

<Principals>

    <Principal id="System">

      <UserId>S-1-5-18</UserId>

      <RunLevel>HighestAvailable</RunLevel>

    </Principal>

</Principals>

<Settings>

    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>

    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

    <ExecutionTimeLimit>PT15M</ExecutionTimeLimit>

    <Hidden>true</Hidden>

    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>

    <Priority>8</Priority>

    <StartWhenAvailable>true</StartWhenAvailable>

    <RunOnlyIfIdle>true</RunOnlyIfIdle>

    <IdleSettings>

      <Duration>PT5M</Duration>

      <WaitTimeout>PT2H</WaitTimeout>

      <StopOnIdleEnd>false</StopOnIdleEnd>

      <RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>

    <MaintenanceSettings>

      <Period>P7D</Period>

      <Deadline>P30D</Deadline>

    </MaintenanceSettings>

</Settings>

<Triggers>

    <RegistrationTrigger />

</Triggers>

<Actions Context="System">

    <Exec>

      <Command>%WinDir%\System32\WinBioPlugIns\FaceFodUninstaller.exe</Command>

    </Exec>

</Actions>

</Task>



<!-- \Microsoft\Windows\PushToInstall\Registration -->
<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

<RegistrationInfo>

    <Version>1.0</Version>

    <SecurityDescriptor>D:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;GRGX;;;SU)</SecurityDescriptor>

    <URI>\Microsoft\Windows\PushToInstall\Registration</URI>

</RegistrationInfo>

<Principals>

    <Principal id="LocalSystem">

      <UserId>S-1-5-18</UserId>

      <RunLevel>HighestAvailable</RunLevel>

    </Principal>

</Principals>

<Settings>

    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>

    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>

    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>

    <StartWhenAvailable>true</StartWhenAvailable>

    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>

    <IdleSettings>

      <StopOnIdleEnd>true</StopOnIdleEnd>

      <RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

    <DisallowStartOnRemoteAppSession>true</DisallowStartOnRemoteAppSession>

    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>

</Settings>

<Triggers>

    <TimeTrigger>

      <StartBoundary>2020-01-25T07:03:40</StartBoundary>

      <Repetition>

      <Interval>P20D</Interval>

      </Repetition>

    </TimeTrigger>

    <WnfStateChangeTrigger>

      <Delay>PT15M</Delay>

      <StateName>750CBCA3290B9641</StateName>

      <Data>01</Data>

    </WnfStateChangeTrigger>

</Triggers>

<Actions Context="LocalSystem">

    <Exec>

      <Command>%windir%\system32\sc.exe</Command>

      <Arguments>start pushtoinstall registration</Arguments>

    </Exec>

</Actions>

</Task>

<!-- \Microsoft\Windows\InstallService\ScanForUpdates -->
<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

<RegistrationInfo>

    <SecurityDescriptor>D:(A;;FA;;;SY)(A;;FRFX;;;BA)</SecurityDescriptor>

    <URI>\Microsoft\Windows\InstallService\ScanForUpdates</URI>

</RegistrationInfo>

<Principals>

    <Principal id="LocalSystem">

      <UserId>S-1-5-18</UserId>

    </Principal>

</Principals>

<Settings>

    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>

    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

    <ExecutionTimeLimit>PT4H</ExecutionTimeLimit>

    <MultipleInstancesPolicy>Queue</MultipleInstancesPolicy>

    <StartWhenAvailable>true</StartWhenAvailable>

    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>

    <IdleSettings>

      <StopOnIdleEnd>true</StopOnIdleEnd>

      <RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>

</Settings>

<Triggers>

    <TimeTrigger>

      <StartBoundary>2014-01-01T08:00:00+08:00</StartBoundary>

      <Repetition>

      <Interval>P1D</Interval>

      </Repetition>

      <RandomDelay>P1D</RandomDelay>

    </TimeTrigger>

    <WnfStateChangeTrigger id="7524BCA33E06830D">

      <Delay>PT15M</Delay>

      <StateName>7524BCA33E06830D</StateName>

    </WnfStateChangeTrigger>

    <TimeTrigger id="ServerRecommendedScheduledRetry">

      <StartBoundary>2014-01-01T08:00:00+08:00</StartBoundary>

      <Enabled>false</Enabled>

    </TimeTrigger>

</Triggers>

<Actions Context="LocalSystem">

    <ComHandler>

      <ClassId>{A558C6A5-B42B-4C98-B610-BF9559143139}</ClassId>

    </ComHandler>

</Actions>

</Task>





floor6ggg 发表于 2020-1-25 22:27:54

我的解法:

直接用 : <StartBoundary>(.*)T
匹配出来的结果:
2020-01-26
2020-01-25
2014-01-01
2014-01-01
[完毕]


进一步限定一下日期以剔除2014的2个数据:
用:<StartBoundary>(202.*?)T
匹配出来的结果:
2020-01-26
2020-01-25
[完毕]

fybhwsx 发表于 2020-1-25 22:31:35

floor6ggg 发表于 2020-1-25 22:27
我的解法:

直接用 : (.*)T


感谢!不过这只是我截取的一部分代码,完整代码还很长,很多这样的日期。
如果分步,也应该先整段提取,然后再提取日期。

floor6ggg 发表于 2020-1-25 22:33:21

本帖最后由 floor6ggg 于 2020-1-25 22:53 编辑

第一个:
(?s)<!-- \\Microsoft\\Windows\\Flighting\\OneSettings\\RefreshCache -->.*?<StartBoundary>(.*?)T
结果:
2020-01-26
[完毕]

floor6ggg 发表于 2020-1-25 22:45:14

第二个:(?s)<!-- \\Microsoft\\Windows\\PushToInstall\\Registration -->.*?<StartBoundary>(.*?)T结果:
2020-01-25
[完毕]

floor6ggg 发表于 2020-1-25 22:48:33

本帖最后由 floor6ggg 于 2020-1-25 22:50 编辑

fybhwsx 发表于 2020-1-25 22:31
感谢!不过这只是我截取的一部分代码,完整代码还很长,很多这样的日期。
如果分步,也应该先整段提取, ...
合并的写法:

(?s)<!-- \\Microsoft\\Windows\\.*?<StartBoundary>(.*?)T测试结果:
2020-01-26
2020-01-25
2014-01-01
[完毕]


要去除2014的数据,括号里面稍加点特征,自行修改啦…………
(?s)<!-- \\Microsoft\\Windows\\.*?<StartBoundary>(202.*?)T

floor6ggg 发表于 2020-1-25 23:04:08

另外一种解法:限定仅该2类段落下面的内容:(?s)<!-- \\Microsoft\\Windows\\(Flighting\\OneSettings\\RefreshCache|PushToInstall\\Registration).*?<StartBoundary>(202.*?)T
结果:

Flighting\OneSettings\RefreshCache
2020-01-26
PushToInstall\Registration
2020-01-25
[完毕]


水平不够,暂时不清楚有没有去处掉返回的和,如果有,请告知,谢谢!!

返回的数组需要后续再加工一下,重新构建自己需要的数组,或者直接采取 step 2 的方式来取值…………

fybhwsx 发表于 2020-1-25 23:04:39

floor6ggg 发表于 2020-1-25 22:48
合并的写法:

测试结果:


日期不能加条件的。我还是按你第一个第二个分两步提取吧,谢谢!!

floor6ggg 发表于 2020-1-25 23:14:03

fybhwsx 发表于 2020-1-25 23:04
日期不能加条件的。我还是按你第一个第二个分两步提取吧,谢谢!!
翻查了一下A大的正则表达神器的说明,你在试一下下面的:
(?s)<!-- \\Microsoft\\Windows\\(?:Flighting\\OneSettings\\RefreshCache|PushToInstall\\Registration).*?<StartBoundary>(.*?)T

floor6ggg 发表于 2020-1-25 23:17:31

本帖最后由 floor6ggg 于 2020-1-25 23:19 编辑

说明是:
(?:abc)(?#匹配abc但不成组)

方框里面限定了段落的特征,前面加了: ?:   ,居然成功了………… A大的神器!!!!没得说!!!厉害!!!
具体原理不清楚,但测试的结果还行…………
结果:
2020-01-26
2020-01-25
[完毕]

fybhwsx 发表于 2020-1-25 23:20:14

floor6ggg 发表于 2020-1-25 23:14
翻查了一下A大的正则表达神器的说明,你在试一下下面的:

太好了,一步解决,谢谢!!

862228699 发表于 2020-2-1 12:28:35

### 友情提示:本脚本由 Au3.REHelper 于 2020/02/01 12:28 自动生成,不保证其正确性,请自行测试 ###
#include <Array.au3>
Local $sSource = _
                '<!-- \Microsoft\Windows\Flighting\OneSettings\RefreshCache -->' & @CRLF & _
                '<?xml version="1.0" encoding="UTF-16"?>' & @CRLF & @CRLF & _
                '<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">' & @CRLF & @CRLF & _
                '<RegistrationInfo>' & @CRLF & @CRLF & _
                '    <SecurityDescriptor>D:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FRFX;;;AU)</SecurityDescriptor>' & @CRLF & @CRLF & _
                '    <Source>$(@%systemroot%\system32\wosc.dll,-602)</Source>' & @CRLF & @CRLF & _
                '    <Author>$(@%systemroot%\system32\wosc.dll,-601)</Author>' & @CRLF & @CRLF & _
                '    <Description>$(@%systemroot%\system32\wosc.dll,-603)</Description>' & @CRLF & @CRLF & _
                '    <URI>\Microsoft\Windows\Flighting\OneSettings\RefreshCache</URI>' & @CRLF & @CRLF & _
                '</RegistrationInfo>' & @CRLF & @CRLF & _
                '<Principals>' & @CRLF & @CRLF & _
                '    <Principal id="LocalSystem">' & @CRLF & @CRLF & _
                '      <UserId>S-1-5-18</UserId>' & @CRLF & @CRLF & _
                '    </Principal>' & @CRLF & @CRLF & _
                '</Principals>' & @CRLF & @CRLF & _
                '<Settings>' & @CRLF & @CRLF & _
                '    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>' & @CRLF & @CRLF & _
                '    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>' & @CRLF & @CRLF & _
                '    <ExecutionTimeLimit>PT5M</ExecutionTimeLimit>' & @CRLF & @CRLF & _
                '    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>' & @CRLF & @CRLF & _
                '    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>' & @CRLF & @CRLF & _
                '    <IdleSettings>' & @CRLF & @CRLF & _
                '      <StopOnIdleEnd>false</StopOnIdleEnd>' & @CRLF & @CRLF & _
                '      <RestartOnIdle>false</RestartOnIdle>' & @CRLF & @CRLF & _
                '    </IdleSettings>' & @CRLF & @CRLF & _
                '    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>' & @CRLF & @CRLF & _
                '</Settings>' & @CRLF & @CRLF & _
                '<Triggers>' & @CRLF & @CRLF & _
                '    <TimeTrigger>' & @CRLF & @CRLF & _
                '      <StartBoundary>2020-01-26T21:10:22+08:00</StartBoundary>' & @CRLF & @CRLF & _
                '      <Repetition>' & @CRLF & @CRLF & _
                '      <Interval>PT3H23M</Interval>' & @CRLF & @CRLF & _
                '      </Repetition>' & @CRLF & @CRLF & _
                '      <RandomDelay>PT1H</RandomDelay>' & @CRLF & @CRLF & _
                '    </TimeTrigger>' & @CRLF & @CRLF & _
                '    <WnfStateChangeTrigger>' & @CRLF & @CRLF & _
                '      <StateName>7538BCA33A019502</StateName>' & @CRLF & @CRLF & _
                '    </WnfStateChangeTrigger>' & @CRLF & @CRLF & _
                '</Triggers>' & @CRLF & @CRLF & _
                '<Actions Context="LocalSystem">' & @CRLF & @CRLF & _
                '    <ComHandler>' & @CRLF & @CRLF & _
                '      <ClassId>{E07647F7-AED2-48D9-9720-939BC24A8A3C}</ClassId>' & @CRLF & @CRLF & _
                '    </ComHandler>' & @CRLF & @CRLF & _
                '</Actions>' & @CRLF & @CRLF & _
                '</Task>' & @CRLF & @CRLF & @CRLF & @CRLF & _
                '<!-- \Microsoft\Windows\HelloFace\FODCleanupTask -->' & @CRLF & _
                '<?xml version="1.0" encoding="UTF-16"?>' & @CRLF & @CRLF & _
                '<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">' & @CRLF & @CRLF & _
                '<RegistrationInfo>' & @CRLF & @CRLF & _
                '    <SecurityDescriptor>D:P(A;;FA;;;BA)(A;;FA;;;SY)(A;;FA;;;NU)</SecurityDescriptor>' & @CRLF & @CRLF & _
                '    <URI>\Microsoft\Windows\HelloFace\FODCleanupTask</URI>' & @CRLF & @CRLF & _
                '</RegistrationInfo>' & @CRLF & @CRLF & _
                '<Principals>' & @CRLF & @CRLF & _
                '    <Principal id="System">' & @CRLF & @CRLF & _
                '      <UserId>S-1-5-18</UserId>' & @CRLF & @CRLF & _
                '      <RunLevel>HighestAvailable</RunLevel>' & @CRLF & @CRLF & _
                '    </Principal>' & @CRLF & @CRLF & _
                '</Principals>' & @CRLF & @CRLF & _
                '<Settings>' & @CRLF & @CRLF & _
                '    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>' & @CRLF & @CRLF & _
                '    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>' & @CRLF & @CRLF & _
                '    <ExecutionTimeLimit>PT15M</ExecutionTimeLimit>' & @CRLF & @CRLF & _
                '    <Hidden>true</Hidden>' & @CRLF & @CRLF & _
                '    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>' & @CRLF & @CRLF & _
                '    <Priority>8</Priority>' & @CRLF & @CRLF & _
                '    <StartWhenAvailable>true</StartWhenAvailable>' & @CRLF & @CRLF & _
                '    <RunOnlyIfIdle>true</RunOnlyIfIdle>' & @CRLF & @CRLF & _
                '    <IdleSettings>' & @CRLF & @CRLF & _
                '      <Duration>PT5M</Duration>' & @CRLF & @CRLF & _
                '      <WaitTimeout>PT2H</WaitTimeout>' & @CRLF & @CRLF & _
                '      <StopOnIdleEnd>false</StopOnIdleEnd>' & @CRLF & @CRLF & _
                '      <RestartOnIdle>false</RestartOnIdle>' & @CRLF & @CRLF & _
                '    </IdleSettings>' & @CRLF & @CRLF & _
                '    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>' & @CRLF & @CRLF & _
                '    <MaintenanceSettings>' & @CRLF & @CRLF & _
                '      <Period>P7D</Period>' & @CRLF & @CRLF & _
                '      <Deadline>P30D</Deadline>' & @CRLF & @CRLF & _
                '    </MaintenanceSettings>' & @CRLF & @CRLF & _
                '</Settings>' & @CRLF & @CRLF & _
                '<Triggers>' & @CRLF & @CRLF & _
                '    <RegistrationTrigger />' & @CRLF & @CRLF & _
                '</Triggers>' & @CRLF & @CRLF & _
                '<Actions Context="System">' & @CRLF & @CRLF & _
                '    <Exec>' & @CRLF & @CRLF & _
                '      <Command>%WinDir%\System32\WinBioPlugIns\FaceFodUninstaller.exe</Command>' & @CRLF & @CRLF & _
                '    </Exec>' & @CRLF & @CRLF & _
                '</Actions>' & @CRLF & @CRLF & _
                '</Task>' & @CRLF & @CRLF & @CRLF & @CRLF & _
                '<!-- \Microsoft\Windows\PushToInstall\Registration -->' & @CRLF & _
                '<?xml version="1.0" encoding="UTF-16"?>' & @CRLF & @CRLF & _
                '<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">' & @CRLF & @CRLF & _
                '<RegistrationInfo>' & @CRLF & @CRLF & _
                '    <Version>1.0</Version>' & @CRLF & @CRLF & _
                '    <SecurityDescriptor>D:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;GRGX;;;SU)</SecurityDescriptor>' & @CRLF & @CRLF & _
                '    <URI>\Microsoft\Windows\PushToInstall\Registration</URI>' & @CRLF & @CRLF & _
                '</RegistrationInfo>' & @CRLF & @CRLF & _
                '<Principals>' & @CRLF & @CRLF & _
                '    <Principal id="LocalSystem">' & @CRLF & @CRLF & _
                '      <UserId>S-1-5-18</UserId>' & @CRLF & @CRLF & _
                '      <RunLevel>HighestAvailable</RunLevel>' & @CRLF & @CRLF & _
                '    </Principal>' & @CRLF & @CRLF & _
                '</Principals>' & @CRLF & @CRLF & _
                '<Settings>' & @CRLF & @CRLF & _
                '    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>' & @CRLF & @CRLF & _
                '    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>' & @CRLF & @CRLF & _
                '    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>' & @CRLF & @CRLF & _
                '    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>' & @CRLF & @CRLF & _
                '    <StartWhenAvailable>true</StartWhenAvailable>' & @CRLF & @CRLF & _
                '    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>' & @CRLF & @CRLF & _
                '    <IdleSettings>' & @CRLF & @CRLF & _
                '      <StopOnIdleEnd>true</StopOnIdleEnd>' & @CRLF & @CRLF & _
                '      <RestartOnIdle>false</RestartOnIdle>' & @CRLF & @CRLF & _
                '    </IdleSettings>' & @CRLF & @CRLF & _
                '    <DisallowStartOnRemoteAppSession>true</DisallowStartOnRemoteAppSession>' & @CRLF & @CRLF & _
                '    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>' & @CRLF & @CRLF & _
                '</Settings>' & @CRLF & @CRLF & _
                '<Triggers>' & @CRLF & @CRLF & _
                '    <TimeTrigger>' & @CRLF & @CRLF & _
                '      <StartBoundary>2020-01-25T07:03:40</StartBoundary>' & @CRLF & @CRLF & _
                '      <Repetition>' & @CRLF & @CRLF & _
                '      <Interval>P20D</Interval>' & @CRLF & @CRLF & _
                '      </Repetition>' & @CRLF & @CRLF & _
                '    </TimeTrigger>' & @CRLF & @CRLF & _
                '    <WnfStateChangeTrigger>' & @CRLF & @CRLF & _
                '      <Delay>PT15M</Delay>' & @CRLF & @CRLF & _
                '      <StateName>750CBCA3290B9641</StateName>' & @CRLF & @CRLF & _
                '      <Data>01</Data>' & @CRLF & @CRLF & _
                '    </WnfStateChangeTrigger>' & @CRLF & @CRLF & _
                '</Triggers>' & @CRLF & @CRLF & _
                '<Actions Context="LocalSystem">' & @CRLF & @CRLF & _
                '    <Exec>' & @CRLF & @CRLF & _
                '      <Command>%windir%\system32\sc.exe</Command>' & @CRLF & @CRLF & _
                '      <Arguments>start pushtoinstall registration</Arguments>' & @CRLF & @CRLF & _
                '    </Exec>' & @CRLF & @CRLF & _
                '</Actions>' & @CRLF & @CRLF & _
                '</Task>' & @CRLF & @CRLF & _
                '<!-- \Microsoft\Windows\InstallService\ScanForUpdates -->' & @CRLF & _
                '<?xml version="1.0" encoding="UTF-16"?>' & @CRLF & @CRLF & _
                '<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">' & @CRLF & @CRLF & _
                '<RegistrationInfo>' & @CRLF & @CRLF & _
                '    <SecurityDescriptor>D:(A;;FA;;;SY)(A;;FRFX;;;BA)</SecurityDescriptor>' & @CRLF & @CRLF & _
                '    <URI>\Microsoft\Windows\InstallService\ScanForUpdates</URI>' & @CRLF & @CRLF & _
                '</RegistrationInfo>' & @CRLF & @CRLF & _
                '<Principals>' & @CRLF & @CRLF & _
                '    <Principal id="LocalSystem">' & @CRLF & @CRLF & _
                '      <UserId>S-1-5-18</UserId>' & @CRLF & @CRLF & _
                '    </Principal>' & @CRLF & @CRLF & _
                '</Principals>' & @CRLF & @CRLF & _
                '<Settings>' & @CRLF & @CRLF & _
                '    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>' & @CRLF & @CRLF & _
                '    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>' & @CRLF & @CRLF & _
                '    <ExecutionTimeLimit>PT4H</ExecutionTimeLimit>' & @CRLF & @CRLF & _
                '    <MultipleInstancesPolicy>Queue</MultipleInstancesPolicy>' & @CRLF & @CRLF & _
                '    <StartWhenAvailable>true</StartWhenAvailable>' & @CRLF & @CRLF & _
                '    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>' & @CRLF & @CRLF & _
                '    <IdleSettings>' & @CRLF & @CRLF & _
                '      <StopOnIdleEnd>true</StopOnIdleEnd>' & @CRLF & @CRLF & _
                '      <RestartOnIdle>false</RestartOnIdle>' & @CRLF & @CRLF & _
                '    </IdleSettings>' & @CRLF & @CRLF & _
                '    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>' & @CRLF & @CRLF & _
                '</Settings>' & @CRLF & @CRLF & _
                '<Triggers>' & @CRLF & @CRLF & _
                '    <TimeTrigger>' & @CRLF & @CRLF & _
                '      <StartBoundary>2014-01-01T08:00:00+08:00</StartBoundary>' & @CRLF & @CRLF & _
                '      <Repetition>' & @CRLF & @CRLF & _
                '      <Interval>P1D</Interval>' & @CRLF & @CRLF & _
                '      </Repetition>' & @CRLF & @CRLF & _
                '      <RandomDelay>P1D</RandomDelay>' & @CRLF & @CRLF & _
                '    </TimeTrigger>' & @CRLF & @CRLF & _
                '    <WnfStateChangeTrigger id="7524BCA33E06830D">' & @CRLF & @CRLF & _
                '      <Delay>PT15M</Delay>' & @CRLF & @CRLF & _
                '      <StateName>7524BCA33E06830D</StateName>' & @CRLF & @CRLF & _
                '    </WnfStateChangeTrigger>' & @CRLF & @CRLF & _
                '    <TimeTrigger id="ServerRecommendedScheduledRetry">' & @CRLF & @CRLF & _
                '      <StartBoundary>2014-01-01T08:00:00+08:00</StartBoundary>' & @CRLF & @CRLF & _
                '      <Enabled>false</Enabled>' & @CRLF & @CRLF & _
                '    </TimeTrigger>' & @CRLF & @CRLF & _
                '</Triggers>' & @CRLF & @CRLF & _
                '<Actions Context="LocalSystem">' & @CRLF & @CRLF & _
                '    <ComHandler>' & @CRLF & @CRLF & _
                '      <ClassId>{A558C6A5-B42B-4C98-B610-BF9559143139}</ClassId>' & @CRLF & @CRLF & _
                '    </ComHandler>' & @CRLF & @CRLF & _
                '</Actions>' & @CRLF & @CRLF & _
                '</Task>'
;~MsgBox(0, '源字符串', $sSource)
Local $aSRE = StringRegExp($sSource, '20\d{2}-\d{2}-\d{2}', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($aSRE), '其中元素为: ' & $aSRE)
_ArrayDisplay($aSRE, UBound($aSRE))

fybhwsx 发表于 2020-2-1 13:43:55

862228699 发表于 2020-2-1 12:28


谢谢,日期不能作为提取条件。floor6ggg 已帮我完美解决了。。

862228699 发表于 2020-2-1 13:54:26

fybhwsx 发表于 2020-2-1 13:43
谢谢,日期不能作为提取条件。floor6ggg 已帮我完美解决了。。

你取的不就是要日期吗?:face (39):

fybhwsx 发表于 2020-2-1 13:56:51

嗯嗯,还有个条件,指定的两个段落中。
页: [1]
查看完整版本: 求个正则提取某一段中的日期【已解决】感谢 floor6ggg