I'd like to extract all numbers in a string that are flanked by two markers/patterns. However, regular expressions in R are my bane.
I have something like this:
string <- "<img src='images/stimuli/32.png' style='width:341.38790035587186px;height: 265px;'><img src='images/stimuli/36.png' style='width:341.38790035587186px;height: 265px;'>"
marker1 <- "images/stimuli/"
marker2 <- ".png"
and want something like this
gsub(paste0(".*", marker1, "*(.*?) *", marker2, ".*"), "\\1", string)
[1] "32" "36"
However I get this:
[1] "32"
PS If someone has a good guide to understand how regular expressions work here, please let me know. I am pretty sure that the answer is pretty simple but I just don't get regex :(