* Removes any comments within parentheses or beginning with a semi-colon. */
| 39 | * Removes any comments within parentheses or beginning with a semi-colon. |
| 40 | */ |
| 41 | QString GcodePreprocessorUtils::removeComment(QString command) |
| 42 | { |
| 43 | static QRegExp rx1("\\(+[^\\(]*\\)+"); |
| 44 | static QRegExp rx2(";.*"); |
| 45 | |
| 46 | // Remove any comments within ( parentheses ) using regex "\([^\(]*\)" |
| 47 | if (command.contains('(')) command.remove(rx1); |
| 48 | |
| 49 | // Remove any comment beginning with ';' using regex ";.*" |
| 50 | if (command.contains(';')) command.remove(rx2); |
| 51 | |
| 52 | return command.trimmed(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Searches for a comment in the input string and returns the first match. |