My PDF file that was created knitrand LaTeXusing RStudio, contains more than 200 indexed terms. I realized too late that it would be nice to boldly index the terms so that I can see them in the PDF file. It seems plausible that there is a way to automate this bias.
The tiny text vector below gives an example of what the text in the .Rnw script looks like, except for the extra return code before the backslash preceding the "index". For a change, there is a space before the indexed word in the second line and an unindexed example in the third line. None of my indexed terms are longer than five words.
text <- c("blah blah \\index{words}words ramble on", "more blah more blah\\index{space words} space words ramble on",
"final blah\\textbf{bold words} ramble on")
library(stringr)
My positive handling efforts using regex and the package stringrto define '\ index {' and pull out the words (indexes) that were indexed failed. My hope was that the regex expression below said: “If you find that the word“ index ”is accompanied by an open bracket, five or less words and a close curly bracket, remove the words.” Nope
wd <- str_extract(string = text, pattern = "(?<=index{\\w{1:5}})\\w+{1:5}")
Error in stri_match_first_regex(string, pattern, opts_regex = attr(pattern, :
Error in {min,max} interval. (U_REGEX_BAD_INTERVAL)
Will someone be good enough to directly establish how to extract the word (s) in braces? My ultimate goal, to be clear, is to enclose the word (s) that follows the open curly brace - the index term - using \ txtbf {}. If you give directions to this step, even better!
Wiktor Stribiżew, , . , "blah blah words ramble on", " blah blah , " .. .Rnw , , \textbf {words} - (-) . , .