Reputation: 2341
I have a file with the following text format:
Blah blah Blahhh<TAB SPACE -(/t character)>1234<TAB SPACE -(/t character)>some other crap blah
The text may look like:
Saturday Evening 1234 Beautiful
I am using the <regex>
library, and I want to use capture groups to only capture the "1234".
I tried:
"\\t(\\d+)\\t"
But when I print the results, it shows the "\t" characters along with the numbers. Any ideas?
Upvotes: 2
Views: 240
Reputation: 43225
\b\d+\b
to include word boundaries.That would ignore the tabs or whitespaces that are matching in your current regex.
Or if you want to match with tabs , use assertions, they will match the tabs, but not capture them :
(?<=\t)\d+(?=\t)
Upvotes: 3
Reputation: 241671
A few details would be useful, like the code you use to do the search and extract the results, but my guess is that you're looking at the wrong match_result index: you should be looking at element 1. See match_results' operator[]
Upvotes: 0