我不知道修改下面的代码,它会向我显示以输入字符开头的单词.例如:如果我输入E或e它显示我"电气,电子,机械"但我只想要"电气,电子"到显示.怎么做?
我正在使用jquery自动完成插件.
source: function(request, response) {
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
response(select.children("option").map(function() {
var text = $(this).text();
if (this.value && (!request.term || matcher.test(text)))
return {
label: text.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" +
$.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>"),
value: text,
option: this
};
}));
Run Code Online (Sandbox Code Playgroud) 我对 powershell 的东西还很陌生。所以这里需要一些帮助。
我想将一个 json 对象作为参数传递给另一个 ps1。从我搜索后读到的内容来看,我需要将其从 json 字符串转换为 powershell 对象。如果我错了,请纠正我。这就是我正在做的
调用脚本:
$jsonParams = "{
`"TaskName`": `"$taskName`",
`"ExitCode`": `"$exitCode`",
`"ErrorMessage`": `"$errorMessage`"
}
$jsonObject = $jsonParams | ConvertFrom-Json
$argumentList = @($param1, $param2, $jsonObject)
Invoke-Expression "& `"$scriptPath`" $argumentList"
Run Code Online (Sandbox Code Playgroud)
并在调用的脚本中 -
param (
[string]$param1,
[string]$param2,
[Microsoft.PowerShell.Commands.JsonObject]$jsonObject
)
Run Code Online (Sandbox Code Playgroud)
但是,调用脚本会抛出错误
ConvertFrom-Json : Invalid object passed in, ':' or '}' expected. (21): {
Run Code Online (Sandbox Code Playgroud)
这段代码有什么问题。另外,将 json 对象传递给调用的脚本后,我应该如何访问其中的值。
谢谢!!