Find files that match the regex pattern -


i need find files match particular pattern in grails.

the files labeled "runid.started.xml". i'm looking find using following regex:

/(? <=\.)(.*?)(?=\.)/ 

i can find files need likit files match pattern. found few examples none seem work. latest:

new file (c:\\mydirectory\\test ).eachfilerecurse (files) {   if (it.name ==~ /(? <=\.)(.*?)(?=\.)/){     println    {       println "nope"     } 

this returns "nope"... i'm new grails i'm not sure i'm going wrong. regex seems correct in online regex tester may wrong.

==~ match operator. meaning string in question must exact match. , (? <=\.)(.*?)(?=\.) doesn't match "runid.started.xml". have 2 options:

  1. use search operator in if statement: =~
  2. write regex exactly matches file names like: \w*\.(\w+)\.\w*

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -