2012-07-02 5 views

답변

2

파일 이름에서 파일 확장명을 가져 오는 방법은 여러 가지가 있습니다. 예를 들어, functx:substring-after-last($filename, '.') 또는 다른 방법 (fn:substring-after)을 사용하여 점 뒤에 부분 문자열을 가져올 수 있습니다. 참조 : xqueryfunctions.com

P. fn:tokenize($filename, '\.')[fn:last()]

+1

'fn : tokenize ($ filename,'\. ') [fn : last()]'가 아니어야합니까? – grtjn

+0

네, 맞습니다. 두 번째 매개 변수는 정규 표현식 패턴을 사용합니다. 감사. –

+0

감사합니다. @AndrewOrlov –

1

나는 자주 교체 다음 사용

fn:replace("c:\a\b\c.d.e.txt", '^(.*\.)?([^\.]+)$', '$2') 

그러나 functx를 사용하는 앤드류에 의해 제안도 좋은 생각입니다. functx 라이브러리의 복사본은 MarkLogic의 후자 버전의 일부로 배포됩니다. 다음 가져 오기를 추가하면 사용할 수 있습니다.

import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy"; 

HTH!

0
그냥 다양한

, 아직 확장 : 생산 다른 표현 : reversed-string($s)는 다음과 같이 정의 할 수있다

reversed-string(substring-before(reversed-string($filePath), '.')) 

:

codepoints-to-string(reverse(string-to-code-points($s))) 

그래서 대체와 전체 표현식은 다음과 같습니다

codepoints-to-string(
      reverse(
       string-to-codepoints(
       substring-before(codepoints-to-string(reverse(string-to-codepoints($filePath))), 
           '.') 
            ) 
        ) 
          ) 
관련 문제