I have an extremely long string in R and would like to extract all substrings that match a certain criteria. The string may look something like this: "some text some text some text [ID: 1234] some text some text [ID: 5678] some text some text [ID: 9999]."
I have seen other questions posted like this that offer gsub as a solution but that seems to be in the scenario when only one substring needs to be extracted and not multiple.
What I would like to achieve as a result is a vector like this:
c("[ID: 1234]", "[ID: 5678]", "[ID: 9999]")