I work with massive strings which need a lot of manipulation.
For example, I might generate a string like this:
Part 1
BoatSection A
ProgrammingPart 2
Partitioning boats for programming.Section AA
Section SQL Entries.
The string would be too large to manually check every part of it. Now I need to split this string into a stringlist by sections and parts. I can think of two options:
A Regular Expression:
QStringList sl = s.split(QRegularExpression("\n(?=Part [0-9]+|Section [A-Z]+)"));
That looks like it should work, but sometimes exceptions slip through (IE: Section SQL Entries would erroneously get split)
Otherwise what I could do is place a marker when I generate the initial string:
🚤💻Part 1
Boat🚤💻Section A
Programming🚤💻Part 2
Partitioning boats for programming.🚤💻Section AA
Section SQL Entries.
Which means that splitting the string would become easy:
QStringList sl = s.split("🚤💻"));
Something tells me though that neither of these are good style or programming practice, but I have up until this point not discussed it nor found an alternative.
- If you were my project manager, would you accept either of these methods?
- If not, what would you suggest I do as a best practice?