I think you need to include the regex OR operator:
String[]tokens = pdfName.split("-|\\.");
What you have will match:
[DASH followed by DOT together] -.
not
[DASH or DOT any of them] -
or .
More Related Contents:
- split US phone number in java? [closed]
- how to write regex for this expression in java
- Regular expression for SSN and phone number [closed]
- How do i find the first un-escaped quotes in Java?
- Incrementing only the digits from an alphanumeric string
- Specific String validation using regex
- Regexp Java for password validation
- Create array of regex matches
- Regex to match only commas not in parentheses?
- Java Regex Replace with Capturing Group
- How to use regex in String.contains() method in Java
- Regex exactly n OR m times
- Detect and extract url from a string?
- What is the regex for “Any positive integer, excluding 0”
- Extract string between two strings in java
- Is Java Regex Thread Safe?
- How to extract parameters from a given url
- Passing parameters to action through ModelDriven in Struts 2
- How to use java regex to match a line
- How to remove the backslash in string using regex in Java?
- Regex pattern including all special characters
- Java; String replace (school project)?
- Remove all non-“word characters” from a String in Java, leaving accented characters?
- java.util.regex.PatternSyntaxException: Dangling meta character ‘+’ near index 0 +
- How to match repeated patterns?
- How to escape a square bracket for Pattern compilation?
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string
- Extract ip addresses from Strings using regex
- Validate if input string is a number between 0-255 using regex