<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request i:type="a:UpdateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<b:key>Target</b:key>
<b:value i:type="a:Entity">
<a:Attributes>
<a:KeyValuePairOfstringanyType>
<b:key>customer_name</b:key>
<b:value i:type="a:OptionSetValue">
<a:Value>SUDHIL-2</a:Value>
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes>
<a:EntityState i:nil="true"/>
<a:FormattedValues/>
<a:Id>f450b346-69e7-e411-80d4-0050568c1f85</a:Id>
<a:LogicalName>customers</a:LogicalName>
<a:RelatedEntities/>
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true"/>
<a:RequestName>Update</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
我的目标是获得如下输出。
$Gateway = "192.168.122.1"
$Ip = "172.18.66.34"
$ IP的第3个八位字节和$ Gateway的第4个八位字节....两者的组合...
我在下面尝试但是没有任何其他逻辑来实现这个
172.18.66.1
答案 0 :(得分:1)
您忘了填写“内容”-caturing组中的模式。
试试这个:
$Gateway -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.(?<content>\d{1,3})"
答案 1 :(得分:1)
Maybe Primitive, but does the job
($Ip -split "\.")[0],($Ip -split "\.")[1],($Ip -split "\.")[2],($Gateway -split "\.")[-1] -join "."
172.18.66.1
works on powershell 2
is that what you mean?
答案 2 :(得分:1)
我知道这不是正则表达式,但这是向您介绍类型[ipaddress]
$Gateway = "192.168.122.1"
$Ip = "172.18.66.34"
(([ipaddress]$Ip).GetAddressBytes()[0..2] + ([ipaddress]$Gateway).GetAddressBytes()[-1]) -join "."
我们使用方法.GetAddressBytes()
来打破八位字节,然后使用数组表示法,连接和简单的-join
来改变地址到您的标准。