문제

I need to split the following string in one go in to an array. following is the string

"camera01_2012-04-13-10-14-12-625.jpg"

My code is String[] fileNameParts = fi.getName().split("[_-.]");

But it throws an exception saying "Exception: Syntax error U_REGEX_INVALID_RANGE near index 4:"

도움이 되었습니까?

해결책

- within character class is used for representing a range

To treat - literally in character class it can be at the beginning or end

With _-. you are representing a range of 95(decimal equivalent to ascii _) to 46(decimal equivalent to ascii .) which is invalid.

Use this regex

[-_.]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top