title: Use R fs::dir_ls to match the beginning of file name?
body: <p>I'm trying to use <code>fs::dir_ls()</code> to return the same results as the <code>list.files()</code> example below. Ultimately, I'm just trying to return files that start with a specific pattern.</p>
  <pre class="lang-r prettyprint-override"><code>path &lt;- &quot;./path/to/files&quot;
  pattern &lt;- &quot;^ABC_.*\\.csv$&quot;
  
  # list files returns the expected output 
  list.files(path = path, pattern = pattern, full.names = T)
  
  # [1] &quot;path/to/files/ABC_1312.csv&quot; 
  # [2] &quot;path/to/files/ABC_ACAB.csv&quot;
  
  # dir_ls does not return any matching files
  fs::dir_ls(path = path, regexp = pattern)
  
  # character(0)
  </code></pre>
  <p>I think the issue here is that the scope of each method's pattern argument differs. The <code>list.files()</code> pattern is only applied to the <code>basename()</code> of the file path, whereas, the <code>dir_ls()</code> regexp argument is being applied to the full path. As a result, the <code>^</code> regex is being applied to the start of the path, instead of the beginning of each file. Is there a way to limit the scope of <code>dir_ls()</code> to only match patterns on the <code>basename()</code> of each file similar to <code>list.files()</code>? Any other insights are appreciated!</p>