I have a String = \"Hello-new-World\". And when i use the split() method with different regex values, it acts differently.
String str = \"Hello-new-world\" Strin
Presumably you're splitting on "|" in the second case - and | has a special meaning within regular expressions. If you want to split on the actual pipe character, you should escape it:
"|"
|
String[] bits = whole.split(Pattern.quote("|"));