Are you wanting to split on the digits? In that case, the correct regular expression is \d. \\d means something else as a regular expression: it would look to split on a '\' character followed by a 'd'.
I'm guessing the source of your confusion is that you're thinking an extra \ is needed to escape the \. But that's when you're putting the regular expression into a Java string literal. When you're passing the regular expression in as a command-line argument that isn't necessary.
So with the code you've got, you call it with the line java SplitMethod "as3ds65df6" "\d". But using a string literal, the following code would give the same result:
So, what if you need to search for periods (.) in your source data? If you just put a period in the regex expression, you get the "any character" behavior. So, what if you try \. ? Now the Java compiler thinks you're trying to create an escape sequence that doesn't exist. The correct syntax is
but if i do so then it doesn't work. for me it is correct "\." not "\\."for dot.