in this string, L"#include <iostream>\n\nusing namespace std;\n\nint main() {\n// Code…
Jump to turn (8)
- 1in this string, L"#include \n\nusing namespace std;\n\nint main() {\n// Code goe
- 2It doesn't work, do you have another alternative?
- 3I used this: But it is also capturing me the \n
- 4OK it works online but using it in wxRegex gives me a compile error. Is there a
- 5this one matches two groups: Match 1 46-50 nint Group 1 46-47 n But doesn't matc
- 6this matches it wrong again, give me another alternative to (?<!\n)int\b
- 7it doesn't work, can you change the code to maybe using the standard regex libra
- 8what if I want to know the matchStart and the matchLen?
- User
in this string, L"#include \n\nusing namespace std;\n\nint main() {\n// Code goes here\n\n// Example output\ncout << "Hello, world!" << endl;\n\nreturn 0;\n}\n"
Which regex can I use to select the int word?
I know using \bint\b works if I didn't had the \n, but unfortunately that is not the case in my example.
- Assistant
You can use the following regex pattern to select the "int" word, even with newlines present:
regex(?:^|\n)intThis pattern will match "int" that occurs at the beginning of a line or after a newline character.
- User
It doesn't work, do you have another alternative?