次のコードexamines the content of inputData.body
for a 32-character string matchと、わかっている限り、すべての一致が配列に配置されます。正規表現が一致しない場合は "false"を返す
// stores an array of any length (0 or more) with the matches
var matches = inputData.body.match(/\b[\w-]{32}\b/g)
// the .map function executes the nameless inner function once for each element of the array and returns a new array with the results
return matches.map(function (m) { return {str: m} })
私は今、例えば、無マッチした表現の場合には何かを返すようにコードが必要です。文字列"false"
。
私はどのように私は条件付きで空虚のイベントで何かを返すに取り掛かる必要があります...
// stores an array of any length (0 or more) with the matches
var matches = inputData.body.match(/\b[\w-]{32}\b/g)
if (matches == null){
return 'false'
}
// the .map function executes the nameless inner function once for each element of the array and returns a new array with the results
return matches.map(function (m) { return {str: m} })
このほか作業を取得することができませんでしたか?
コードは機能的にラップされていますか? –
私はあなたのコードが動作するはずだと思います。 – Barmar
呼び出し元が関数の結果として文字列を取得する準備ができていますか?おそらく配列が必要です。 – Barmar