파일명에서 확장자 제외

Jmnote (토론 | 기여)님의 2021년 9월 28일 (화) 22:39 판 (새 문서: ==개요== ;How to get the filename without the extension ;파일명에서 확장자 제외 ==Bash== <syntaxhighlight lang='bash' run> MYFILE=hello.txt basename $MYFILE .txt </syntax...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

How to get the filename without the extension
파일명에서 확장자 제외

2 Bash

MYFILE=hello.txt
basename $MYFILE .txt

3 Java

public class MyClass {
    public static void main(String args[]) {
      String myfile = "hello.txt";
      System.out.println(myfile.replaceFirst("[.][^.]+$", ""));
    }
}

4 PHP

$myfile = "hello.txt";
echo pathinfo($myfile)['filename'];

5 Python

import os
print(os.path.splitext("hello.txt")[0])

6 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}