20230224 1309 

 

동기) 문자열에서 특정 문자가 여러 번 나올 경우 맨 마지막 위치를 찾고 싶다.

 

(예) 년월일 포맷에서 날짜만 뽑기

zstr:="2002-08-09"
  ans:=InStr(zstr,"-",,0)
  ans1:=StrLen(zstr)
  zcount:=ans1-ans
  StringMid, zoutput, zstr, ans+1, zcount+1
  MsgBox,% ans ", " ans1 ", "  zcount ", "  zoutput
return
^ESC:: ExitApp

 

결과

(note) 파일 경로에서 파일 이름만 추출하고 싶다면 간단하게 SplitPath 함수를 쓰면 된다.

; https://www.autohotkey.com/docs/v1/lib/SplitPath.htm

ztmp:="c:\aaa\bbb\ccc.txt"
  SplitPath, ztmp, zfile
  MsgBox,% zfile
return

^ESC:: ExitApp
ExitApp
Posted by Weneedu
,


출처: https://privatedevelopnote.tistory.com/81 [개인노트]