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 .
Related Posts:
- Using or ‘|’ in regex [duplicate]
- How to match “any character” in regular expression?
- Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used
- How to match “any character” in regular expression?
- What does regular expression \\s*,\\s* do?
- Range of valid character for a base 64 encoding
- List of all special characters that need to be escaped in a regex
- Regular Expressions on Punctuation
- How to extract a substring using regex
- Whitespace Matching Regex – Java
- How to represent a fix number of repeats in regular expression?
- Using regex to match any character except =
- How to use regex in String.contains() method in Java
- Whitespace Matching Regex – Java
- Difference between regex [A-z] and [a-zA-Z]
- Regex pattern including all special characters
- Split string into array of character strings
- Java regex email
- How to format strings in Java
- What exactly is Apache Camel?
- What is an instance variable in Java?
- How does the Java ‘for each’ loop work?
- How does the Java ‘for each’ loop work?
- What does “Could not find or load main class” mean?
- How do I create a file and write to it?
- When to use LinkedList over ArrayList in Java?
- How to convert a char to a String?
- How do you create a dictionary in Java? [closed]
- How do I declare and initialize an array in Java?
- How do I generate random integers within a specific range in Java?
- “Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0″ with ArrayList?
- Raising a number to a power in Java
- exception in thread ‘main’ java.lang.NoClassDefFoundError:
- java.io.FileNotFoundException: the system cannot find the file specified
- How to parse this string in Java?
- Double array initialization in Java
- I want to declare an empty array in java and then I want do update it but the code is not working
- Convert java.util.Date to String
- How do I do a deep copy of a 2d array in Java?
- Returning an empty array
- Java Security: Illegal key size or default parameters?
- Could not reserve enough space for object heap
- Eclipse: Java was started but returned error code=13
- Why java unknown: import org.apache.commons.codec.binary.Base64;?
- Extracting .jar file with command line
- Java; String replace (using regular expressions)?
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- Why do I get “Exception; must be caught or declared to be thrown” when I try to compile my Java code?
- Check jdk/JRE is installed and get path for jvm.dll
- Good Java graph algorithm library?
- Integrate Ant builder into Eclipse: Error “Variable references empty selection”
- Spring Maven clean error – The requested profile “pom.xml” could not be activated because it does not exist
- Java Class File Editor
- Error Importing SSL certificate : Not an X.509 Certificate
- How do I draw a triangle?
- warning: [options] bootstrap class path not set in conjunction with -source 1.5
- Class ‘Room’ is abstract; cannot be instantiated
- Creating a maze solving algorithm in Java
- IDEA: javac: source release 1.7 requires target release 1.7
- Can we write our own iterator in Java?
- local variables referenced from a lambda expression must be final or effectively final
- java.lang.IllegalMonitorStateException: object not locked by thread before wait()?
- WebServlet cannot be resolved to a type
- How do I print out the value of this boolean? (Java)
- How to add an object to an ArrayList in Java
- Picked up _JAVA_OPTIONS: -Xmx256M
- When to use static methods
- How to serialize an object into a string
- Getting the array length of a 2D array in Java
- Java String to SHA1
- How do I call one constructor from another in Java?
- Does Java have something like C#’s ref and out keywords?
- How to upload a file and JSON data in Postman?
- What is the difference between i++ & ++i in a for loop?
- when to throw FileNotFoundException
- How to use ArrayUtils for array of objects, it doesn’t delete the content of an array
- The ResourceConfig instance does not contain any root resource classes
- Error: Could not find or load main class net.minecraft.launchwrapper.Launch when launching Minecraft 1.12.2 with Forge
- IllegalArgumentException: Bound must be positive
- Eclipse is executing the wrong Java file
- Understanding BufferedImage.getRGB output values
- What is the purpose of creating static object in Java?
- How to print a method in java
- build-impl.xml:1031: The module has not been deployed
- Spring-Security-Oauth2: Full authentication is required to access this resource
- Why is System.out.print() not working?
- setMnemonic() and call a method by pressing the key
- What is `AnyType` in java generics
- “insufficient memory for the Java Runtime Environment ” message in eclipse
- Android: how to create Switch case from this?
- Read next word in java
- Convert float to double without losing precision
- Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError: Java heap space
- How do the post increment (i++) and pre increment (++i) operators work in Java?
- Manually throw an exception
- Spring boot: Unable to start embedded Tomcat servlet container
- How does paintComponent work?
- toring and Retrieving ArrayList values from hashmap
- Could not find or load main class with a Jar File
- “uses unchecked or unsafe operations” [duplicate]