<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>stringr | JDW BLOG</title>
    <link>https://www.jdwblog.com/tag/stringr/</link>
      <atom:link href="https://www.jdwblog.com/tag/stringr/index.xml" rel="self" type="application/rss+xml" />
    <description>stringr</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>ko</language><copyright>© 2026. JDW all rights reserved.</copyright><lastBuildDate>Sat, 03 Oct 2020 00:00:00 +0000</lastBuildDate>
    <image>
      <url>https://www.jdwblog.com/media/icon_hua25d9a1a07874235ea074645b87e53ff_12380_512x512_fill_lanczos_center_2.png</url>
      <title>stringr</title>
      <link>https://www.jdwblog.com/tag/stringr/</link>
    </image>
    
    <item>
      <title>[R] stringr 패키지를 사용한 정규표현식</title>
      <link>https://www.jdwblog.com/post/regexwithstringr/</link>
      <pubDate>Sat, 03 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://www.jdwblog.com/post/regexwithstringr/</guid>
      <description>&lt;img src=&#34;images/stringr_logo.png&#34; alt=&#34;&#34; width=&#34;50%&#34;/&gt;
&lt;p&gt; 이전 장에서 R에서 사용되는 정규표현식에 대해 알아보았었는데요. 오늘은 정규표현식을 텍스트 데이터를 처리할때 사용하는 패키지인 &lt;strong&gt;&lt;code&gt;stringr&lt;/code&gt;&lt;/strong&gt; 과 함께 사용하는 방법에 대해 알아보도록 하겠습니다.&lt;/p&gt;



&lt;h1 id=&#34;stringr&#34;&gt;stringr&lt;a href=&#34;#stringr&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;p&gt;  &lt;strong&gt;&lt;code&gt;stringr&lt;/code&gt;&lt;/strong&gt; 패키지는 Rstudio의 Hadley Wickham이 개발한 패키지입니다. &lt;strong&gt;&lt;code&gt;dplyr&lt;/code&gt;&lt;/strong&gt; , &lt;strong&gt;&lt;code&gt;ggplot2&lt;/code&gt;&lt;/strong&gt; 등과 같이 데이터를 깔끔한(tidy) 방식으로 처리하는것을 지향하는 &lt;strong&gt;&lt;code&gt;tidyverse&lt;/code&gt;&lt;/strong&gt; 패키지군에 속해 있으며, 그 중 &lt;strong&gt;&lt;code&gt;stringr&lt;/code&gt;&lt;/strong&gt; 은 문자열 처리에 특화된 패키지입니다. &amp;lsquo;string&amp;rsquo;의 준말인 &lt;code&gt;str_&lt;/code&gt;이 함수 머릿말에 항상 등장하는 것이 특징입니다.&lt;/p&gt;
&lt;p&gt;  &lt;strong&gt;&lt;code&gt;stringr&lt;/code&gt;&lt;/strong&gt; 패키지의 주요 기능을 아래와 같이 분류하였고 각 경우에 맞는 상황을 가정하여 알아보도록 하겠습니다.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;#%ec%9d%bc%ec%b9%98&#34;&gt;1. 특정 패턴과 &lt;strong&gt;&amp;lsquo;일치&amp;rsquo;&lt;/strong&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href=&#34;#%ec%b9%b4%ec%9a%b4%ed%8c%85&#34;&gt;2. 특정 패턴의 &lt;strong&gt;&amp;lsquo;카운팅&amp;rsquo;&lt;/strong&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href=&#34;#%ed%8f%ac%ed%95%a8&#34;&gt;3. 특정 패턴이 &lt;strong&gt;&amp;lsquo;포함&amp;rsquo;&lt;/strong&gt; 된 경우&lt;/a&gt; &lt;br&gt;
&lt;a href=&#34;#%ec%9c%84%ec%b9%98&#34;&gt;4. 특정 패턴의 &lt;strong&gt;&amp;lsquo;위치&amp;rsquo;&lt;/strong&gt; 를 반환&lt;/a&gt; &lt;br&gt;
&lt;a href=&#34;#%eb%b0%94%ea%be%b8%ea%b8%b0&#34;&gt;5. 특정 패턴을 새로운 것으로 &lt;strong&gt;&amp;lsquo;바꾸는&amp;rsquo;&lt;/strong&gt; 경우&lt;/a&gt; &lt;br&gt;
&lt;a href=&#34;#%eb%82%98%eb%88%84%ea%b8%b0&#34;&gt;6. 특정 패턴을 기준으로 &lt;strong&gt;&amp;lsquo;나누는&amp;rsquo;&lt;/strong&gt; 경우&lt;/a&gt;&lt;br&gt;&lt;/p&gt;



&lt;h2 id=&#34;예제-문장&#34;&gt;예제 문장&lt;a href=&#34;#%ec%98%88%ec%a0%9c-%eb%ac%b8%ec%9e%a5&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt; 연습용으로 사용할 문장은 stringr 패키지에 내장되어 있는 &lt;code&gt;sentence&lt;/code&gt; 데이터를 사용하겠습니다. &lt;code&gt;sentence&lt;/code&gt;는 총 1000문장으로 구성되어 있는데, 문장 전체를 사용할 필요가 없으므로 10문장 정도만을 추려서 사용하도록 하겠습니다.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;regex_sentences &amp;lt;- stringr::sentences[1:10] # 예제용 문장 생성

regex_sentences
#&amp;gt;  [1] &amp;quot;The birch canoe slid on the smooth planks.&amp;quot; 
#&amp;gt;  [2] &amp;quot;Glue the sheet to the dark blue background.&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;s easy to tell the depth of a well.&amp;quot;     
#&amp;gt;  [4] &amp;quot;These days a chicken leg is a rare dish.&amp;quot;   
#&amp;gt;  [5] &amp;quot;Rice is often served in round bowls.&amp;quot;       
#&amp;gt;  [6] &amp;quot;The juice of lemons makes fine punch.&amp;quot;      
#&amp;gt;  [7] &amp;quot;The box was thrown beside the parked truck.&amp;quot;
#&amp;gt;  [8] &amp;quot;The hogs were fed chopped corn and garbage.&amp;quot;
#&amp;gt;  [9] &amp;quot;Four hours of steady work faced us.&amp;quot;        
#&amp;gt; [10] &amp;quot;Large size in stockings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&#34;일치&#34;&gt;일치&lt;a href=&#34;#%ec%9d%bc%ec%b9%98&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_detect()&lt;/code&gt;함수는 특정 문자 혹은 패턴(정규표현식)과 일치하는 경우를 찾을때 사용하며, 실행 결과로서 boolean(참, 거짓)을 반환합니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_detect(regex_sentences, &#39;[aeiou]&#39;) # 알파벳 모음 &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39;가 있을 경우 TRUE
#&amp;gt;  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_detect(regex_sentences, &#39;[easy]&#39;)  # 알파벳 &#39;e&#39; or &#39;a&#39; or &#39;s&#39; or &#39;y&#39;가 있을 경우 TRUE 
#&amp;gt;  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_detect(regex_sentences, &#39;(easy)&#39;)  # 알파벳 &#39;easy&#39;가 있을 경우 TRUE 
#&amp;gt;  [1] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_extract()&lt;/code&gt;함수는 특정 문자 혹은 패턴(정규표현식)과 일치하는 경우, 그것을 반환합니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_extract(regex_sentences, &#39;[aeiou]&#39;) # &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39; 글자가 존재하면 그것을 반환 
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;u&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_extract(regex_sentences, &#39;[:punct:]&#39;) # 문장부호가 존재하면 그것을 반환 
#&amp;gt;  [1] &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;&#39;&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot; &amp;quot;.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; 함수는 조건에 일치하는 결과를 반환하였는데요. 자세히 보면 조건에 일치한 것이 여러개 있음에도 불구하고 오직 최초 값만을 반환하는 것을 볼 수 있습니다. 그렇다면 조건에 일치하는 모든 값을 찾고자 할 땐 어떻게 해야할까요? 바로 &lt;code&gt;str_extract_all()&lt;/code&gt; 함수를 사용하면 됩니다. &lt;strong&gt;&lt;code&gt;stringr&lt;/code&gt;&lt;/strong&gt; 패키지 함수 중 몇몇의 함수는 함수 말미에 &lt;code&gt;_all&lt;/code&gt;이 붙는 함수들이 있습니다. 이들 함수들은 조건에 맞는 모든 값을 반환하는 특징이 있습니다.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_extract_all(regex_sentences, &#39;[aeiou]&#39;)
#&amp;gt; [[1]]
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot;
#&amp;gt; 
#&amp;gt; [[2]]
#&amp;gt;  [1] &amp;quot;u&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;u&amp;quot; &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;u&amp;quot;
#&amp;gt; 
#&amp;gt; [[3]]
#&amp;gt; [1] &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot;
#&amp;gt; 
#&amp;gt; [[4]]
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;a&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;a&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot;
#&amp;gt; 
#&amp;gt; [[5]]
#&amp;gt;  [1] &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;o&amp;quot; &amp;quot;u&amp;quot; &amp;quot;o&amp;quot;
#&amp;gt; 
#&amp;gt; [[6]]
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;u&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;u&amp;quot;
#&amp;gt; 
#&amp;gt; [[7]]
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot; &amp;quot;u&amp;quot;
#&amp;gt; 
#&amp;gt; [[8]]
#&amp;gt;  [1] &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot; &amp;quot;a&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot;
#&amp;gt; 
#&amp;gt; [[9]]
#&amp;gt;  [1] &amp;quot;o&amp;quot; &amp;quot;u&amp;quot; &amp;quot;o&amp;quot; &amp;quot;u&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;a&amp;quot; &amp;quot;e&amp;quot; &amp;quot;u&amp;quot;
#&amp;gt; 
#&amp;gt; [[10]]
#&amp;gt;  [1] &amp;quot;a&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;e&amp;quot; &amp;quot;i&amp;quot; &amp;quot;o&amp;quot; &amp;quot;i&amp;quot; &amp;quot;i&amp;quot; &amp;quot;a&amp;quot; &amp;quot;o&amp;quot; &amp;quot;e&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_extract_all(regex_sentences, &#39;[:punct:]&#39;)
#&amp;gt; [[1]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[2]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[3]]
#&amp;gt; [1] &amp;quot;&#39;&amp;quot; &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[4]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[5]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[6]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[7]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[8]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[9]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
#&amp;gt; 
#&amp;gt; [[10]]
#&amp;gt; [1] &amp;quot;.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;code&gt;str_extract_all()&lt;/code&gt; 함수의 결과, 조건에 부합하는 모든 값이 list 형으로 반환된 것을 볼 수 있습니다.&lt;/p&gt;



&lt;h3 id=&#34;카운팅&#34;&gt;카운팅&lt;a href=&#34;#%ec%b9%b4%ec%9a%b4%ed%8c%85&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_count()&lt;/code&gt;함수는 특정 문자 혹은 패턴(정규표현식)과 일치하는 경우를 계산합니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_count(regex_sentences, &#39;[aeiou]&#39;) # &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39; 문자의 개수를 반환 
#&amp;gt;  [1] 11 13  9 12 11 12 11 12 11 11
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_count(regex_sentences, &#39;^(The)&#39;) # 시작이 &#39;The&#39;인 경우를 셈 
#&amp;gt;  [1] 1 0 0 1 0 1 1 1 0 0
&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&#34;포함&#34;&gt;포함&lt;a href=&#34;#%ed%8f%ac%ed%95%a8&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_subset()&lt;/code&gt;함수는 특정 문자 혹은 패턴(정규표현식)이 포함된 경우를 반환합니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_subset(regex_sentences, &#39;[aeiou]&#39;) # &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39; 문자가 포함된 경우를 반환 
#&amp;gt;  [1] &amp;quot;The birch canoe slid on the smooth planks.&amp;quot; 
#&amp;gt;  [2] &amp;quot;Glue the sheet to the dark blue background.&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;s easy to tell the depth of a well.&amp;quot;     
#&amp;gt;  [4] &amp;quot;These days a chicken leg is a rare dish.&amp;quot;   
#&amp;gt;  [5] &amp;quot;Rice is often served in round bowls.&amp;quot;       
#&amp;gt;  [6] &amp;quot;The juice of lemons makes fine punch.&amp;quot;      
#&amp;gt;  [7] &amp;quot;The box was thrown beside the parked truck.&amp;quot;
#&amp;gt;  [8] &amp;quot;The hogs were fed chopped corn and garbage.&amp;quot;
#&amp;gt;  [9] &amp;quot;Four hours of steady work faced us.&amp;quot;        
#&amp;gt; [10] &amp;quot;Large size in stockings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_subset(regex_sentences, &#39;^(The)&#39;)  # 시작이 &#39;The&#39;인 문장을 반환
#&amp;gt; [1] &amp;quot;The birch canoe slid on the smooth planks.&amp;quot; 
#&amp;gt; [2] &amp;quot;These days a chicken leg is a rare dish.&amp;quot;   
#&amp;gt; [3] &amp;quot;The juice of lemons makes fine punch.&amp;quot;      
#&amp;gt; [4] &amp;quot;The box was thrown beside the parked truck.&amp;quot;
#&amp;gt; [5] &amp;quot;The hogs were fed chopped corn and garbage.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_subset(regex_sentences, &#39;p[:alpha:]{1,}\\.$&#39;) # &#39;p&#39;뒤에 알파벳이 한번 이상 나오면서 마침표로 끝나는 경우 
#&amp;gt; [1] &amp;quot;The birch canoe slid on the smooth planks.&amp;quot;
#&amp;gt; [2] &amp;quot;The juice of lemons makes fine punch.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&#34;위치&#34;&gt;위치&lt;a href=&#34;#%ec%9c%84%ec%b9%98&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_locate()&lt;/code&gt;함수는 특정 문자 혹은 패턴(정규표현식)에 맞는 경우의 시작 지점과 끝 지점을 반환합니다. R에 기본적으로 내장되어 있는 영어 소문자 데이터인 &lt;code&gt;letters&lt;/code&gt;를 통해 알아보겠습니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;letters
#&amp;gt;  [1] &amp;quot;a&amp;quot; &amp;quot;b&amp;quot; &amp;quot;c&amp;quot; &amp;quot;d&amp;quot; &amp;quot;e&amp;quot; &amp;quot;f&amp;quot; &amp;quot;g&amp;quot; &amp;quot;h&amp;quot; &amp;quot;i&amp;quot; &amp;quot;j&amp;quot; &amp;quot;k&amp;quot; &amp;quot;l&amp;quot; &amp;quot;m&amp;quot; &amp;quot;n&amp;quot; &amp;quot;o&amp;quot; &amp;quot;p&amp;quot; &amp;quot;q&amp;quot; &amp;quot;r&amp;quot; &amp;quot;s&amp;quot;
#&amp;gt; [20] &amp;quot;t&amp;quot; &amp;quot;u&amp;quot; &amp;quot;v&amp;quot; &amp;quot;w&amp;quot; &amp;quot;x&amp;quot; &amp;quot;y&amp;quot; &amp;quot;z&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; 패턴의 위치를 찾기 위해선 하나로 묶인 데이터가 필요하므로 &lt;code&gt;str_c()&lt;/code&gt; 함수를 사용하여 하나의 벡터로 묶었습니다. (&lt;code&gt;str_c()&lt;/code&gt;함수는 __&lt;code&gt;stringr&lt;/code&gt;__패키지의 문자를 결합하는 함수. R의 내장함수인 &lt;code&gt;paste()&lt;/code&gt;와 동일하게 동작)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;letters &amp;lt;- str_c(letters, collapse = &#39;&#39;);

letters # 하나의 벡터값으로 변환 
#&amp;gt; [1] &amp;quot;abcdefghijklmnopqrstuvwxyz&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;[a-z]+&#39;) # &#39;a&#39;부터 &#39;z&#39; 까지의 문자가 한개 이상 나오는 경우의 시작과 끝을 반환 
#&amp;gt;      start end
#&amp;gt; [1,]     1  26
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;^[a][a-z]+[z]$&#39;) # 시작이 &#39;a&#39;이며, 바로 뒤에 &#39;a&#39; 부터 &#39;z&#39;까지의 문자 중 하나가 한번 이상 나오며, 끝이 &#39;z&#39;인 경우의 시작 지점과 끝 지점을 반환.
#&amp;gt;      start end
#&amp;gt; [1,]     1  26
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;^[a-z][a-z]+$&#39;) # 시작이 &#39;a&#39; 부터 &#39;z&#39; 까지의 문자 중 하나이며, 끝이 &#39;a&#39; 부터 &#39;z&#39; 까지의 문자 중 하나인 경우의 시작 지점과 끝 지점.
#&amp;gt;      start end
#&amp;gt; [1,]     1  26
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;(abcde)&#39;) # &#39;abcde&#39;의 시작 지점과 끝 지점을 반환 
#&amp;gt;      start end
#&amp;gt; [1,]     1   5
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;(xyz)&#39;) # &#39;xyz&#39;의 시작 지점과 끝 지점을 반환  
#&amp;gt;      start end
#&amp;gt; [1,]    24  26
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;code&gt;str_locate_all()&lt;/code&gt;함수를 통해 조건에 맞는 모든 값의 위치를 추출할 수 있습니다.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate(letters, &#39;[aeiou][^aeiou]+&#39;) # &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39;문자 뒤에 &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39; 문자가 아닌 문자가 하나 이상 나오는 최초 경우의 시작 지점과 끝 지점을 반환 
#&amp;gt;      start end
#&amp;gt; [1,]     1   4
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_locate_all(letters, &#39;[aeiou][^aeiou]+&#39;) # &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39;문자 뒤에 &#39;a&#39; or &#39;e&#39; or &#39;i&#39; or &#39;o&#39; or &#39;u&#39; 문자가 아닌 문자가 하나 이상 나오는 모든 경우의 시작 지점과 끝 지점을 반환 
#&amp;gt; [[1]]
#&amp;gt;      start end
#&amp;gt; [1,]     1   4
#&amp;gt; [2,]     5   8
#&amp;gt; [3,]     9  14
#&amp;gt; [4,]    15  20
#&amp;gt; [5,]    21  26
&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&#34;바꾸기&#34;&gt;바꾸기&lt;a href=&#34;#%eb%b0%94%ea%be%b8%ea%b8%b0&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_replace()&lt;/code&gt;는 특정 문자 혹은 패턴(정규표현식)에 맞는 경우를 새로운 문자로 바꾸는 함수입니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace(regex_sentences, &#39;k&#39;, &amp;quot;&#39;K&#39;&amp;quot;) # 최초로 매칭되는 문자 k를 &#39;K&#39;로 변환  
#&amp;gt;  [1] &amp;quot;The birch canoe slid on the smooth plan&#39;K&#39;s.&amp;quot; 
#&amp;gt;  [2] &amp;quot;Glue the sheet to the dar&#39;K&#39; blue background.&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;s easy to tell the depth of a well.&amp;quot;       
#&amp;gt;  [4] &amp;quot;These days a chic&#39;K&#39;en leg is a rare dish.&amp;quot;   
#&amp;gt;  [5] &amp;quot;Rice is often served in round bowls.&amp;quot;         
#&amp;gt;  [6] &amp;quot;The juice of lemons ma&#39;K&#39;es fine punch.&amp;quot;      
#&amp;gt;  [7] &amp;quot;The box was thrown beside the par&#39;K&#39;ed truck.&amp;quot;
#&amp;gt;  [8] &amp;quot;The hogs were fed chopped corn and garbage.&amp;quot;  
#&amp;gt;  [9] &amp;quot;Four hours of steady wor&#39;K&#39; faced us.&amp;quot;        
#&amp;gt; [10] &amp;quot;Large size in stoc&#39;K&#39;ings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace(regex_sentences, &#39;\\.&#39;, &#39;\\?&#39;) # 최초로 매칭되는 마침표를 물음표로 변환 
#&amp;gt;  [1] &amp;quot;The birch canoe slid on the smooth planks?&amp;quot; 
#&amp;gt;  [2] &amp;quot;Glue the sheet to the dark blue background?&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;s easy to tell the depth of a well?&amp;quot;     
#&amp;gt;  [4] &amp;quot;These days a chicken leg is a rare dish?&amp;quot;   
#&amp;gt;  [5] &amp;quot;Rice is often served in round bowls?&amp;quot;       
#&amp;gt;  [6] &amp;quot;The juice of lemons makes fine punch?&amp;quot;      
#&amp;gt;  [7] &amp;quot;The box was thrown beside the parked truck?&amp;quot;
#&amp;gt;  [8] &amp;quot;The hogs were fed chopped corn and garbage?&amp;quot;
#&amp;gt;  [9] &amp;quot;Four hours of steady work faced us?&amp;quot;        
#&amp;gt; [10] &amp;quot;Large size in stockings is hard to sell?&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; 마찬가지로 &lt;code&gt;str_replace_all()&lt;/code&gt;함수를 통해 조건에 맞는 모든 값을 바꿀 수 있습니다.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace(regex_sentences, &#39;[:alpha:]{1,}&#39;, &#39;word&#39;) # 최초로 매칭되는 알파뱃이 한개 이상인 경우를 &#39;word&#39;로 변환 
#&amp;gt;  [1] &amp;quot;word birch canoe slid on the smooth planks.&amp;quot; 
#&amp;gt;  [2] &amp;quot;word the sheet to the dark blue background.&amp;quot; 
#&amp;gt;  [3] &amp;quot;word&#39;s easy to tell the depth of a well.&amp;quot;    
#&amp;gt;  [4] &amp;quot;word days a chicken leg is a rare dish.&amp;quot;     
#&amp;gt;  [5] &amp;quot;word is often served in round bowls.&amp;quot;        
#&amp;gt;  [6] &amp;quot;word juice of lemons makes fine punch.&amp;quot;      
#&amp;gt;  [7] &amp;quot;word box was thrown beside the parked truck.&amp;quot;
#&amp;gt;  [8] &amp;quot;word hogs were fed chopped corn and garbage.&amp;quot;
#&amp;gt;  [9] &amp;quot;word hours of steady work faced us.&amp;quot;         
#&amp;gt; [10] &amp;quot;word size in stockings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace_all(regex_sentences, &#39;[:alpha:]{1,}&#39;, &#39;word&#39;) # 알파뱃이 한개 이상인 모든 값을 &#39;word&#39;라는 단어로 변환 
#&amp;gt;  [1] &amp;quot;word word word word word word word word.&amp;quot;          
#&amp;gt;  [2] &amp;quot;word word word word word word word word.&amp;quot;          
#&amp;gt;  [3] &amp;quot;word&#39;word word word word word word word word word.&amp;quot;
#&amp;gt;  [4] &amp;quot;word word word word word word word word word.&amp;quot;     
#&amp;gt;  [5] &amp;quot;word word word word word word word.&amp;quot;               
#&amp;gt;  [6] &amp;quot;word word word word word word word.&amp;quot;               
#&amp;gt;  [7] &amp;quot;word word word word word word word word.&amp;quot;          
#&amp;gt;  [8] &amp;quot;word word word word word word word word.&amp;quot;          
#&amp;gt;  [9] &amp;quot;word word word word word word word.&amp;quot;               
#&amp;gt; [10] &amp;quot;word word word word word word word word.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace(regex_sentences, &#39;[:space:]&#39;, &#39;&#39;) # 최초로 매칭되는 띄어쓰기를 공백으로 변환 
#&amp;gt;  [1] &amp;quot;Thebirch canoe slid on the smooth planks.&amp;quot; 
#&amp;gt;  [2] &amp;quot;Gluethe sheet to the dark blue background.&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;seasy to tell the depth of a well.&amp;quot;     
#&amp;gt;  [4] &amp;quot;Thesedays a chicken leg is a rare dish.&amp;quot;   
#&amp;gt;  [5] &amp;quot;Riceis often served in round bowls.&amp;quot;       
#&amp;gt;  [6] &amp;quot;Thejuice of lemons makes fine punch.&amp;quot;      
#&amp;gt;  [7] &amp;quot;Thebox was thrown beside the parked truck.&amp;quot;
#&amp;gt;  [8] &amp;quot;Thehogs were fed chopped corn and garbage.&amp;quot;
#&amp;gt;  [9] &amp;quot;Fourhours of steady work faced us.&amp;quot;        
#&amp;gt; [10] &amp;quot;Largesize in stockings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_replace_all(regex_sentences, &#39;[:space:]&#39;, &#39;&#39;) # 매칭되는 모든 띄어쓰기를 공백으로 변환 
#&amp;gt;  [1] &amp;quot;Thebirchcanoeslidonthesmoothplanks.&amp;quot; 
#&amp;gt;  [2] &amp;quot;Gluethesheettothedarkbluebackground.&amp;quot;
#&amp;gt;  [3] &amp;quot;It&#39;seasytotellthedepthofawell.&amp;quot;      
#&amp;gt;  [4] &amp;quot;Thesedaysachickenlegisararedish.&amp;quot;    
#&amp;gt;  [5] &amp;quot;Riceisoftenservedinroundbowls.&amp;quot;      
#&amp;gt;  [6] &amp;quot;Thejuiceoflemonsmakesfinepunch.&amp;quot;     
#&amp;gt;  [7] &amp;quot;Theboxwasthrownbesidetheparkedtruck.&amp;quot;
#&amp;gt;  [8] &amp;quot;Thehogswerefedchoppedcornandgarbage.&amp;quot;
#&amp;gt;  [9] &amp;quot;Fourhoursofsteadyworkfacedus.&amp;quot;       
#&amp;gt; [10] &amp;quot;Largesizeinstockingsishardtosell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&#34;나누기&#34;&gt;나누기&lt;a href=&#34;#%eb%82%98%eb%88%84%ea%b8%b0&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;str_split()&lt;/code&gt;는 특정 문자 혹은 패턴(정규표현식)을 기준으로 값을 나누는 함수입니다. 이때 기준이된 문자 혹은 패턴은 제거됩니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_split(regex_sentences, &#39;[:upper:]&#39;) # 대문자를 기준으로 분절 
#&amp;gt; [[1]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                         
#&amp;gt; [2] &amp;quot;he birch canoe slid on the smooth planks.&amp;quot;
#&amp;gt; 
#&amp;gt; [[2]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                          
#&amp;gt; [2] &amp;quot;lue the sheet to the dark blue background.&amp;quot;
#&amp;gt; 
#&amp;gt; [[3]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                     
#&amp;gt; [2] &amp;quot;t&#39;s easy to tell the depth of a well.&amp;quot;
#&amp;gt; 
#&amp;gt; [[4]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                       
#&amp;gt; [2] &amp;quot;hese days a chicken leg is a rare dish.&amp;quot;
#&amp;gt; 
#&amp;gt; [[5]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                    &amp;quot;ice is often served in round bowls.&amp;quot;
#&amp;gt; 
#&amp;gt; [[6]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                    
#&amp;gt; [2] &amp;quot;he juice of lemons makes fine punch.&amp;quot;
#&amp;gt; 
#&amp;gt; [[7]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                          
#&amp;gt; [2] &amp;quot;he box was thrown beside the parked truck.&amp;quot;
#&amp;gt; 
#&amp;gt; [[8]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                          
#&amp;gt; [2] &amp;quot;he hogs were fed chopped corn and garbage.&amp;quot;
#&amp;gt; 
#&amp;gt; [[9]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                   &amp;quot;our hours of steady work faced us.&amp;quot;
#&amp;gt; 
#&amp;gt; [[10]]
#&amp;gt; [1] &amp;quot;&amp;quot;                                       
#&amp;gt; [2] &amp;quot;arge size in stockings is hard to sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_split(regex_sentences, &#39;\\b&#39;) # 문자의 바운더리를 기준으로 분절 
#&amp;gt; [[1]]
#&amp;gt;  [1] &amp;quot;&amp;quot;       &amp;quot;The&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;birch&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;canoe&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;slid&amp;quot;  
#&amp;gt;  [9] &amp;quot; &amp;quot;      &amp;quot;on&amp;quot;     &amp;quot; &amp;quot;      &amp;quot;the&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;smooth&amp;quot; &amp;quot; &amp;quot;      &amp;quot;planks&amp;quot;
#&amp;gt; [17] &amp;quot;.&amp;quot;     
#&amp;gt; 
#&amp;gt; [[2]]
#&amp;gt;  [1] &amp;quot;&amp;quot;           &amp;quot;Glue&amp;quot;       &amp;quot; &amp;quot;          &amp;quot;the&amp;quot;        &amp;quot; &amp;quot;         
#&amp;gt;  [6] &amp;quot;sheet&amp;quot;      &amp;quot; &amp;quot;          &amp;quot;to&amp;quot;         &amp;quot; &amp;quot;          &amp;quot;the&amp;quot;       
#&amp;gt; [11] &amp;quot; &amp;quot;          &amp;quot;dark&amp;quot;       &amp;quot; &amp;quot;          &amp;quot;blue&amp;quot;       &amp;quot; &amp;quot;         
#&amp;gt; [16] &amp;quot;background&amp;quot; &amp;quot;.&amp;quot;         
#&amp;gt; 
#&amp;gt; [[3]]
#&amp;gt;  [1] &amp;quot;&amp;quot;      &amp;quot;It&amp;quot;    &amp;quot;&#39;&amp;quot;     &amp;quot;s&amp;quot;     &amp;quot; &amp;quot;     &amp;quot;easy&amp;quot;  &amp;quot; &amp;quot;     &amp;quot;to&amp;quot;    &amp;quot; &amp;quot;    
#&amp;gt; [10] &amp;quot;tell&amp;quot;  &amp;quot; &amp;quot;     &amp;quot;the&amp;quot;   &amp;quot; &amp;quot;     &amp;quot;depth&amp;quot; &amp;quot; &amp;quot;     &amp;quot;of&amp;quot;    &amp;quot; &amp;quot;     &amp;quot;a&amp;quot;    
#&amp;gt; [19] &amp;quot; &amp;quot;     &amp;quot;well&amp;quot;  &amp;quot;.&amp;quot;    
#&amp;gt; 
#&amp;gt; [[4]]
#&amp;gt;  [1] &amp;quot;&amp;quot;        &amp;quot;These&amp;quot;   &amp;quot; &amp;quot;       &amp;quot;days&amp;quot;    &amp;quot; &amp;quot;       &amp;quot;a&amp;quot;       &amp;quot; &amp;quot;      
#&amp;gt;  [8] &amp;quot;chicken&amp;quot; &amp;quot; &amp;quot;       &amp;quot;leg&amp;quot;     &amp;quot; &amp;quot;       &amp;quot;is&amp;quot;      &amp;quot; &amp;quot;       &amp;quot;a&amp;quot;      
#&amp;gt; [15] &amp;quot; &amp;quot;       &amp;quot;rare&amp;quot;    &amp;quot; &amp;quot;       &amp;quot;dish&amp;quot;    &amp;quot;.&amp;quot;      
#&amp;gt; 
#&amp;gt; [[5]]
#&amp;gt;  [1] &amp;quot;&amp;quot;       &amp;quot;Rice&amp;quot;   &amp;quot; &amp;quot;      &amp;quot;is&amp;quot;     &amp;quot; &amp;quot;      &amp;quot;often&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;served&amp;quot;
#&amp;gt;  [9] &amp;quot; &amp;quot;      &amp;quot;in&amp;quot;     &amp;quot; &amp;quot;      &amp;quot;round&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;bowls&amp;quot;  &amp;quot;.&amp;quot;     
#&amp;gt; 
#&amp;gt; [[6]]
#&amp;gt;  [1] &amp;quot;&amp;quot;       &amp;quot;The&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;juice&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;of&amp;quot;     &amp;quot; &amp;quot;      &amp;quot;lemons&amp;quot;
#&amp;gt;  [9] &amp;quot; &amp;quot;      &amp;quot;makes&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;fine&amp;quot;   &amp;quot; &amp;quot;      &amp;quot;punch&amp;quot;  &amp;quot;.&amp;quot;     
#&amp;gt; 
#&amp;gt; [[7]]
#&amp;gt;  [1] &amp;quot;&amp;quot;       &amp;quot;The&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;box&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;was&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;thrown&amp;quot;
#&amp;gt;  [9] &amp;quot; &amp;quot;      &amp;quot;beside&amp;quot; &amp;quot; &amp;quot;      &amp;quot;the&amp;quot;    &amp;quot; &amp;quot;      &amp;quot;parked&amp;quot; &amp;quot; &amp;quot;      &amp;quot;truck&amp;quot; 
#&amp;gt; [17] &amp;quot;.&amp;quot;     
#&amp;gt; 
#&amp;gt; [[8]]
#&amp;gt;  [1] &amp;quot;&amp;quot;        &amp;quot;The&amp;quot;     &amp;quot; &amp;quot;       &amp;quot;hogs&amp;quot;    &amp;quot; &amp;quot;       &amp;quot;were&amp;quot;    &amp;quot; &amp;quot;      
#&amp;gt;  [8] &amp;quot;fed&amp;quot;     &amp;quot; &amp;quot;       &amp;quot;chopped&amp;quot; &amp;quot; &amp;quot;       &amp;quot;corn&amp;quot;    &amp;quot; &amp;quot;       &amp;quot;and&amp;quot;    
#&amp;gt; [15] &amp;quot; &amp;quot;       &amp;quot;garbage&amp;quot; &amp;quot;.&amp;quot;      
#&amp;gt; 
#&amp;gt; [[9]]
#&amp;gt;  [1] &amp;quot;&amp;quot;       &amp;quot;Four&amp;quot;   &amp;quot; &amp;quot;      &amp;quot;hours&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;of&amp;quot;     &amp;quot; &amp;quot;      &amp;quot;steady&amp;quot;
#&amp;gt;  [9] &amp;quot; &amp;quot;      &amp;quot;work&amp;quot;   &amp;quot; &amp;quot;      &amp;quot;faced&amp;quot;  &amp;quot; &amp;quot;      &amp;quot;us&amp;quot;     &amp;quot;.&amp;quot;     
#&amp;gt; 
#&amp;gt; [[10]]
#&amp;gt;  [1] &amp;quot;&amp;quot;          &amp;quot;Large&amp;quot;     &amp;quot; &amp;quot;         &amp;quot;size&amp;quot;      &amp;quot; &amp;quot;         &amp;quot;in&amp;quot;       
#&amp;gt;  [7] &amp;quot; &amp;quot;         &amp;quot;stockings&amp;quot; &amp;quot; &amp;quot;         &amp;quot;is&amp;quot;        &amp;quot; &amp;quot;         &amp;quot;hard&amp;quot;     
#&amp;gt; [13] &amp;quot; &amp;quot;         &amp;quot;to&amp;quot;        &amp;quot; &amp;quot;         &amp;quot;sell&amp;quot;      &amp;quot;.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&#34;language-r&#34;&gt;str_split(regex_sentences, &#39;\\s&#39;) # 띄어쓰기를 기준으로 분절 
#&amp;gt; [[1]]
#&amp;gt; [1] &amp;quot;The&amp;quot;     &amp;quot;birch&amp;quot;   &amp;quot;canoe&amp;quot;   &amp;quot;slid&amp;quot;    &amp;quot;on&amp;quot;      &amp;quot;the&amp;quot;     &amp;quot;smooth&amp;quot; 
#&amp;gt; [8] &amp;quot;planks.&amp;quot;
#&amp;gt; 
#&amp;gt; [[2]]
#&amp;gt; [1] &amp;quot;Glue&amp;quot;        &amp;quot;the&amp;quot;         &amp;quot;sheet&amp;quot;       &amp;quot;to&amp;quot;          &amp;quot;the&amp;quot;        
#&amp;gt; [6] &amp;quot;dark&amp;quot;        &amp;quot;blue&amp;quot;        &amp;quot;background.&amp;quot;
#&amp;gt; 
#&amp;gt; [[3]]
#&amp;gt; [1] &amp;quot;It&#39;s&amp;quot;  &amp;quot;easy&amp;quot;  &amp;quot;to&amp;quot;    &amp;quot;tell&amp;quot;  &amp;quot;the&amp;quot;   &amp;quot;depth&amp;quot; &amp;quot;of&amp;quot;    &amp;quot;a&amp;quot;     &amp;quot;well.&amp;quot;
#&amp;gt; 
#&amp;gt; [[4]]
#&amp;gt; [1] &amp;quot;These&amp;quot;   &amp;quot;days&amp;quot;    &amp;quot;a&amp;quot;       &amp;quot;chicken&amp;quot; &amp;quot;leg&amp;quot;     &amp;quot;is&amp;quot;      &amp;quot;a&amp;quot;      
#&amp;gt; [8] &amp;quot;rare&amp;quot;    &amp;quot;dish.&amp;quot;  
#&amp;gt; 
#&amp;gt; [[5]]
#&amp;gt; [1] &amp;quot;Rice&amp;quot;   &amp;quot;is&amp;quot;     &amp;quot;often&amp;quot;  &amp;quot;served&amp;quot; &amp;quot;in&amp;quot;     &amp;quot;round&amp;quot;  &amp;quot;bowls.&amp;quot;
#&amp;gt; 
#&amp;gt; [[6]]
#&amp;gt; [1] &amp;quot;The&amp;quot;    &amp;quot;juice&amp;quot;  &amp;quot;of&amp;quot;     &amp;quot;lemons&amp;quot; &amp;quot;makes&amp;quot;  &amp;quot;fine&amp;quot;   &amp;quot;punch.&amp;quot;
#&amp;gt; 
#&amp;gt; [[7]]
#&amp;gt; [1] &amp;quot;The&amp;quot;    &amp;quot;box&amp;quot;    &amp;quot;was&amp;quot;    &amp;quot;thrown&amp;quot; &amp;quot;beside&amp;quot; &amp;quot;the&amp;quot;    &amp;quot;parked&amp;quot; &amp;quot;truck.&amp;quot;
#&amp;gt; 
#&amp;gt; [[8]]
#&amp;gt; [1] &amp;quot;The&amp;quot;      &amp;quot;hogs&amp;quot;     &amp;quot;were&amp;quot;     &amp;quot;fed&amp;quot;      &amp;quot;chopped&amp;quot;  &amp;quot;corn&amp;quot;     &amp;quot;and&amp;quot;     
#&amp;gt; [8] &amp;quot;garbage.&amp;quot;
#&amp;gt; 
#&amp;gt; [[9]]
#&amp;gt; [1] &amp;quot;Four&amp;quot;   &amp;quot;hours&amp;quot;  &amp;quot;of&amp;quot;     &amp;quot;steady&amp;quot; &amp;quot;work&amp;quot;   &amp;quot;faced&amp;quot;  &amp;quot;us.&amp;quot;   
#&amp;gt; 
#&amp;gt; [[10]]
#&amp;gt; [1] &amp;quot;Large&amp;quot;     &amp;quot;size&amp;quot;      &amp;quot;in&amp;quot;        &amp;quot;stockings&amp;quot; &amp;quot;is&amp;quot;        &amp;quot;hard&amp;quot;     
#&amp;gt; [7] &amp;quot;to&amp;quot;        &amp;quot;sell.&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;



&lt;h1 id=&#34;참고자료&#34;&gt;참고자료&lt;a href=&#34;#%ec%b0%b8%ea%b3%a0%ec%9e%90%eb%a3%8c&#34;&gt;&lt;svg class=&#34;anchor-symbol&#34; height=&#34;26&#34; width=&#34;26&#34; viewBox=&#34;0 0 22 22&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path d=&#34;M0 0h24v24H0z&#34; fill=&#34;currentColor&#34;&gt;&lt;/path&gt;
&lt;path d=&#34;M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z&#34;&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/rstudio/cheatsheets/blob/master/regex.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Rstudio Regular Expression Cheatsheet&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/rstudio/cheatsheets/blob/master/strings.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Rstudio Stringr Cheatsheets&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;https://sulgik.github.io/r4ds/strings.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;R을 활용한 데이터과학 - 문자열&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
