I want to scrape data from some text and dump it into an array. Consider the following text as example data:
| Example Data
| Title: This is a sample title
|
In Ruby, as in PCRE and Boost, you may make use of the \K match reset operator:
\Kkeeps the text matched so far out of the overall regex match.h\Kdmatches only the seconddinadhd.
So, you may use
/:[[:blank:]]*\K.+/ # To only match horizontal whitespaces with `[[:blank:]]`
/:\s*\K.+/ # To match any whitespace with `\s`
Seee the Rubular demo #1 and the Rubular demo #2 and
Details
: - a colon[[:blank:]]* - 0 or more horizontal whitespace chars\K - match reset operator discarding the text matched so far from the overall match memory buffer.+ - matches and consumes any 1 or more chars other than line break chars (use /m modifier to match any chars including line break chars).