Reputation: 461
Could you explain how to get the substring between tokens [
and ;
The original string:
a [
b [
text1;
text2;
c [
text3;
text4;
]
]
]
And that I want:
text1;
text2;
text3;
text4;
Upvotes: 1
Views: 231
Reputation: 726987
A quick approach would be to search from the back for a ';'
, then search back for '['
starting from that position, and split the resulting string at the semicolons. Repeat the same process until you can no longer find a semicolon ';'
.
A better approach would be to write a simple recursive descent parser with a single rule: the detection would be a lot more reliable if errors in the source are present.
Upvotes: 2