title: Regex //divxlc in text analysis in R book code
body: <p>I am currently studying the Text Analysis in R book by <a href="https://stackoverflow.com/users/5468471/julia-silge">Silge</a> and <a href="https://stackoverflow.com/users/712603/david-robinson">Robinson</a> and given my newbie status I can't come around to understanding exactly how this regex <code>"^chapter [\\divxlc]"</code> works out the chapter numbers when tidying the texts.  I have checked the regex101 engine (I may ignore also how to make it work for what I need).  Can somebody help me out in figuring it out?  This is the code I am referring to:</p>
  
  <pre><code>tidy_books &lt;- austen_books() %&gt;%
    group_by(book) %&gt;%
    mutate(linenumber = row_number(),
       chapter = cumsum(str_detect(text, regex("^chapter [\\divxlc]", 
                                               ignore_case = TRUE)))) %&gt;%
   ungroup() %&gt;%
   unnest_tokens(word, text)
  </code></pre>
  
  <p>My take on it is that this will identify chapter numbers also written in roman numerals(`\d would have sufficed for decimals, I think).  Is it so?  Is the a general formula to identify chapter numbers regardless of its numbering?  If so, how would it identify chapters III, XXI, etc where some roman numerals repeat?</p>
  
  <p>I would appreciate any indication or reference to look for clarification.  </p>
  
  <p>Thanks in advance. </p>