| 104 | } |
| 105 | |
| 106 | const char *QRegexSearch::SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) |
| 107 | { |
| 108 | Q_UNUSED(doc); |
| 109 | |
| 110 | qInfo(Q_FUNC_INFO); |
| 111 | |
| 112 | Q_ASSERT(match.isValid()); |
| 113 | Q_ASSERT(match.hasMatch()); |
| 114 | |
| 115 | // Get the captured text and replace the match |
| 116 | QString newString = match.captured(); |
| 117 | newString.replace(match.regularExpression(), QByteArray(text, *length)); |
| 118 | |
| 119 | // TODO: figure out why this has to be new'd and can't be an instantiated class member |
| 120 | if (substituted) { |
| 121 | delete substituted; |
| 122 | } |
| 123 | |
| 124 | substituted = new QByteArray(newString.toUtf8()); |
| 125 | *length = substituted->length(); |
| 126 | return substituted->data(); |
| 127 | } |