I want to split the string by "/" and ignore "/" inside the outer parentheses.
Sample input string:
"Apple 001/(Orange (002/003) ABC)/Mango 003 )/( ASDJ/(Watermelon )004)/Apple 002 ASND/(Mango)"
Expected output in string array:
["Apple 001", "(Orange (002/003) ABC)", "Mango 003 )/( ASDJ", "(Watermelon )004)", "Apple 002 ASND", "(Mango)"]
This is my regex:
/(?=(?:[^()]*([^()]*))*[^()]*$)
But it can only support simple string like this:
"Apple 001/(Orange 002/003 ABC)/Mango 003 ASDJ/(Watermelon 004)/Apple 002 ASND/(Mango)"
If there is inner parentheses, the result is incorrect.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…