2

I have input String in following format:

"xyz PQ (All) (foo \"(abc\" def) test \"elasticSearch\" (test \"pqr\" stu) "

I want to tokenize it such that the string should be split by space excluding double quotes and parentheses, so it should give below result

xyz
PQ
All
foo "(abc" def
test
"elasticSearch"
test "pqr" stu

Any help would be appreciated.

0

2 Answers 2

1

(\([^)]+\))|([^ ]+)

Explanations and usage here.

Sign up to request clarification or add additional context in comments.

Comments

1

following regex solves the purpose:

(\\([^)]+\\))|([^ \"]*\"[^\"]*\")|([^ ]+)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.