루프 결과를 배열에 추가하려고합니다.배열에 루프 추가
이<cfset mobNumbers = ArrayNew(1)>
<cfloop query = "staffLoop">
<cfscript>
mobileNo = staffLoop.mobileno;
mobileNo = mobileNo.replaceAll("[^0-9]", "");
ext = staffLoop.extension;
ext = ext.replaceAll("[^0-9]", "");
if (Left(mobileNo, 2) == "07" || Left(mobileNo, 3) == "447") {
recipient = mobileNo;
} else if (Left(ext, 2) == "07" || Left(ext, 3) == "447") {
recipient = ext;
} else {
recipient = "";
}
if (Left(recipient, 2) == "07") {
recipient = "447" & Right(recipient, Len(recipient) - 2);
}
if (Len(recipient) == 12) {
[send text code]
}
</cfscript>
</cfloop>
<cfset ArrayAppend(mobNumbers, "recipient")>
목표는 모든 휴대 전화 번호의 배열을 얻을 수 있습니다 :
여기 내 코드입니다.
내 코드가 작동하지 않고 일부 조사를 마쳤습니다. 어떻게해야할지 모르겠습니다. 어떤 아이디어?
가능한 경우 cfscript를 사용하지 않는 것이 좋지만 내 솔루션에는 non-cfscript를 사용하고 싶습니다.
오, 그래. –
감사합니다. 관련 메모에서'mobileNo = mobileNo.replaceAll' 때문에 코드 오류가 발생합니다. replaceAll을 좋아하지 않으며 이유가 확실하지 않습니다. 어쩌면 다른 질문을 시작해야 할 것입니다. 'mobileNo = mobileNo.replaceAll'을 주석 처리하면 다른 replaceAll과 오류가 발생하지 않습니다. – Alias
replaceAll은 String 클래스의 자바 메서드이므로 ColdFusion에서는 직접 지원되지 않지만 사용할 수 있습니다. 벤 네델 (Ben Nadel)의 예제를 보시려면 여기를보십시오. http://www.bennadel.com/blog/1488-ColdFusion-Regular-Expressions-Do-Not-Support-Character-Class-Intersection-Or-Subtraction.htm – barnyr