Extract dates from strings in R
<p>I have a vector of strings as shown below. I want to extract dates.</p>

<pre><code>check_values &lt;- c("deficit based on wage statement 7/14/ to 7/17/2015",
                "Deficit Due: $1205.73 -$879.63= $326.10 x 70%=$228.2",
                "Deficit Due for 12 wks pd - 7/14/15 thru 10/5/15;",
                "Deficit due to wage statement: 4/22/15 thru 5/12/15",
                "depos transcript 7/10/15 for 7/8/15 depos",
                "difference owed for 4/25/15-5/22/15",
                "tpd 4:30:2015 - 5:22:2015",
                "Medical TREATMENT DATES:  6/30/2015 -  6/30/2015",
                "4/25/15-5/22/15",
                "Medical")

                check_values &lt;- as.data.table(check_values)
                names(check_values) &lt;- "check_memo"
</code></pre>

<p>Before extracting dates, I want to create a Date_Flag. I have used following code but it gives different output:</p>

<pre><code>check_values$Date_Flag &lt;- ifelse(grepl("([0-9]+)(/|-|:)([0-9]+)(/|-|:)([0-9]+)(/|-|:)", check_values$check_memo), 1, 0)
 #[1] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE
 #Expected Output: FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE
</code></pre>

<p>After this Date_Flag is created, I want to extract dates (both parts). Can somebody please tell me what is wrong with above regular regression?</p>

<p>Thanks</p>