I have a String which i need to split based on the space and the exact matching quotes.
If the
string = \"It is fun \\\"to write\\\" regular\\\"expressi
You are running into a fundamental limitation of regular expressions here. In general they can't detect recursion, depth, etc.
So in your string:
"It is fun \"to write\" regular\"expression"
Both the space between to
and write
and the space between \"
and regular
are all inside quote marks. Regex is not able to "count" the number of quotes in a flexible way and take action based on it.
You will need to write your own string parser for this (or use an existing one). Regex can't handle it though.