我有一个类似下面的字符串,我需要使用PowerShell解析它。我只想将字符串保持为“EntityPath”并取出实体路径后的所有内容:
Endpoint=sb://abcdefg.servicebus.windows.net/;SharedAccessKeyName=listenkey_1137;SharedAccessKey=W2c26OiBwae9f/vgPcJWgtD709oTTJu1VlB8i4OkqUc=;EntityPath=listen_1137
答案 0 :(得分:0)
var app = angular.module('tutorial', ['ngRoute','ngMaterial'])
app.service('myService',
function myService(data) {
var service = this;
service.validator = function(data) {
if (data.name.$valid)
return true
else
return false
}
// return service
}
)
app.controller('myCtrl',['$scope', '$http', '$location', 'myService', myCtrl])
function myCtrl($scope, $http, $location, myService) {
$scope.editorEnabled = false;
myService = this;
$scope.insertemployee = function(empinfo) {
if (myservice.validator(empinfo)) {
console.log(empinfo.name)
console.log(empinfo.email)
console.log(empinfo.address)
$http.post('insertEmp.php',{'name':empinfo.name, 'email': empinfo.email, 'address':empinfo.address}).then(function(data) {
console.log(data)
})
}
}
这可能有效
答案 1 :(得分:0)
我不确定你现在在问什么,但这是我想的第二个问题。我会尝试理解你的问题,因为它有些破碎的英语。
function Invoke-MyWork($testStr)
{
$parts = $testStr -split "EntityPath"
$parts[0]
}
$originalValue = "Endpoint=sb://abcdefg.servicebus.windows.net/;SharedAccessKeyName=listenkey_1137;SharedAccessKey=W2c26OiBwae9f/vgPcJWgtD709oTTJu1VlB8i4OkqUc=;EntityPath=listen_1137"
$upToEntityPath = Invoke-MyWork $originalValue
Write-Host "UpToEntityPath: $($upToEntityPath)"
Write-Host "OriginalValue: $($originalValue)"
答案 2 :(得分:0)
这是使用 regex 的解决方案。
$ep = "Endpoint=sb://abcdefg.servicebus.windows.net/;SharedAccessKeyName=listenkey_1137;SharedAccessKey=W2c26OiBwae9f/vgPcJWgtD709oTTJu1VlB8i4OkqUc=;EntityPath=listen_1137"
[regex]::Match($ep, 'EntityPath=([^;|\s]+)').Groups[1].Value # output: listen_1137
[regex]::Match($ep, '(EntityPath=[^;|\s]+)').Groups[1].Value # output: EntityPath=listen_1137
答案 3 :(得分:0)
试试这个:
$mystring="Endpoint=sb://abcdefg.servicebus.windows.net/;SharedAccessKeyName=listenkey_1137;SharedAccessKey=W2c26OiBwae9f/vgPcJWgtD709oTTJu1VlB8i4OkqUc=;EntityPath=listen_1137"
$NameValue=$mystring -replace ";", "`n" | ConvertFrom-StringData
$NameValue.EntityPath