2011-11-10 2 views
-2

문자열을 통해 분할 기능 이상한 문제가있어. 내 예제를 보아라. 어떻게 알아낼 수 있니? 기본적으로 String에서 "\"를 제거합니까?문자열 분할 숨기기 및 ""문자를 제거

--- C : 다음과 같이

public function code01():void { 
    qrShow("C:/Documents and Settings/me/Desktop/a.gif;C:/Documents and Settings/me/Desktop/b.gif"); 
    qrShow("C:\Documents and Settings\me\Desktop\a.gif;C:\Documents and Settings\me\Desktop\b.gif"); 
} 

public function qrShow(u:String):void{ 
    var imgArray:Array = u.split(";"); 
    for each(var addrs:String in imgArray) { 
     trace (" --- " + addrs); 
    } 
} 

결과는/문서 및 설정/ME/데스크탑/

a.gif

--- C :/문서 및 설정/me/Desktop/b.gif

--- C : Documents and SettingsmeDesktopa.gif < --- 왜 "\"가 없습니까?

--- C : Documents and SettingsmeDesktop.gif < --- "\"및 "b"가 변경되지 않은 이유는 무엇입니까?

플래시의 버그입니까?

+0

이스케이프 문자 심판 : http://en.wikipedia.org/wiki/Escape_character – LisztLi

답변

3

당신은 (다른 백 슬래시) 백 슬래시를 이스케이프해야합니다. 예를 들어

이 실행하려고 :

trace("\"); 

당신은 오류가 발생합니다.

는이 작업을 수행해야합니다

trace("\\"); // Output: \ 
3

아니요, 실제로는 백 슬래시 \이 ActionScript에서 이스케이프 문자이기 때문입니다. 다음 문자 뒤에 특별한 의미가없는 경우 백 슬래시는 무시됩니다. 그러나 일반적으로 그 뒤에 오는 문자의 의미를 변경하는 데 사용됩니다. 그래서 백 슬래시를 두 배로, 코드를 수정합니다 :

qrShow("C:\\Documents and Settings\\me\\Desktop\\a.gif;C:\\Documents and Settings\\me\\Desktop\\b.gif"); 
+1

그것은 슬래시 (모든 운영 체제의 작동) 앞으로 사용하는 것이 좋습니다 –

+0

@JonatanHedborg : 그것은 질문에 포함되었지만 ... – Ryan