다음 코드 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