title: Extracting number after a specific phrase
body: <p>I've been trying to write two regular expressions to doing the following two tasks:</p>
  <ol>
  <li>Pull the numbers after the phrase &quot;EDG ICD HCUP CCS&quot;</li>
  <li>Pull the words after &quot;EDG ICD HCUP CCS 159 (PREDICTIVE MODELS-VERSION 1.0)-&quot;</li>
  </ol>
  <p>I'd like to have the numbers stored in a column named &quot;category&quot; and the words stored in &quot;diagnosis&quot;</p>
  <p>The strings are located in the column name &quot;GROUPER_NAME&quot;.</p>
  <pre><code>df &lt;- structure(list(GROUPER_ID = structure(c(&quot;9001742130&quot;, &quot;9001742138&quot;, 
  &quot;9001742058&quot;, &quot;9001742062&quot;, &quot;9001742102&quot;, &quot;9001742247&quot;, &quot;9001742055&quot;, 
  &quot;9001742158&quot;, &quot;9001742036&quot;, &quot;9001742053&quot;), label = &quot;GROUPER_ID&quot;, format.sas = &quot;$&quot;), 
      GROUPER_NAME = structure(c(&quot;EDG ICD HCUP CCS 130 (PREDICTIVE MODELS-VERSION 1.0)-PLEURISY; PNEUMOTHORAX; PULMONARY COLLAPSE&quot;, 
      &quot;EDG ICD HCUP CCS 138 (PREDICTIVE MODELS-VERSION 1.0)-ESOPHAGEAL DISORDERS&quot;, 
      &quot;EDG ICD HCUP CCS 58 (PREDICTIVE MODELS-VERSION 1.0)-OTHER NUTRITIONAL; ENDOCRINE; AND METABOLIC DISORDERS&quot;, 
      &quot;EDG ICD HCUP CCS 62 (PREDICTIVE MODELS-VERSION 1.0)-COAGULATION AND HEMORRHAGIC DISORDERS&quot;, 
      &quot;EDG ICD HCUP CCS 102 (PREDICTIVE MODELS-VERSION 1.0)-NONSPECIFIC CHEST PAIN&quot;, 
      &quot;EDG ICD HCUP CCS 247 (PREDICTIVE MODELS-VERSION 1.0)-LYMPHADENITIS&quot;, 
      &quot;EDG ICD HCUP CCS 55 (PREDICTIVE MODELS-VERSION 1.0)-FLUID AND ELECTROLYTE DISORDERS&quot;, 
      &quot;EDG ICD HCUP CCS 158 (PREDICTIVE MODELS-VERSION 1.0)-CHRONIC KIDNEY DISEASE&quot;, 
      &quot;EDG ICD HCUP CCS 36 (PREDICTIVE MODELS-VERSION 1.0)-CANCER OF THYROID&quot;, 
      &quot;EDG ICD HCUP CCS 53 (PREDICTIVE MODELS-VERSION 1.0)-DISORDERS OF LIPID METABOLISM&quot;
      ), label = &quot;GROUPER_NAME&quot;, format.sas = &quot;$&quot;)), row.names = c(NA, 
  -10L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>For the first example, I'd like to pull &quot;159&quot; and &quot;URINARY TRACT INFECTIONS&quot; and put them in columns &quot;category&quot; and &quot;diagnosis,&quot; respectively. I've trying to alter some of the solutions on here to fit my scenario, but I'm really awful with regular expressions and cannot get anything to work. Any help would be greatly appreciated!</p>