ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msor...@softhome.net
Subject Re: AW: AW: generate file list with parameterized regexp
Date Wed, 21 May 2008 15:43:56 GMT
My humblest apologies--I did not state my problem clearly. I want to find a 
set of files whose contents (not the file name) includes a string based on 
the name of the file containing it. That is, for each file path/xxx.yyy, I 
want to know if the file contains a string like this:
"See doc page at path/xxx.html". 

So <containsregexp> seemed the most promising, as discussed, but it uses 
only a "constant" regexp, not a parameterized regexp. 


Jan.Materne@rzf.fin-nrw.de writes: 

> Ok, I had a look into the source of <containsregexp> org.apache.tools.ant.types.selectors.ContainsRegexpSelector.
> It checks the 'content' of the file ...
> - directories are always selected
> - files are selected its content matches the regexp expression 
> 
> I'll update the manual to make this more clear. 
> 
> After that I think that you want to select files which 'names' match the regexp.
> The <filename> selector supports simple pattern matching like '*' but no real regexps.
> I havent found a builtin one, but with BSF+Java4 or Java6 you could use a scripted selector.
> <project>
>     <property name="searchRegexp" value="six.*"/>
>     <pathconvert property="selected" pathsep="${line.separator}">
>         <fileset dir=".">
>             <scriptselector language="javascript" setbeans="true">
>                 self.setSelected( filename.match(searchRegexp) != null );
>             </scriptselector>
>         </fileset>
>     </pathconvert>
>     <echo>Selected files for ${search.regexp}</echo>
>     <echo>${selected}</echo>
> </project> 
> 
>  
> 
> Jan
>   
> 
>> -----Urspr√ľngliche Nachricht-----
>> Von: msorens@softhome.net [mailto:msorens@softhome.net] 
>> Gesendet: Dienstag, 20. Mai 2008 17:47
>> An: Ant Users List
>> Betreff: Re: AW: generate file list with parameterized regexp 
>> 
>> Yes I have tried "containsregexp". As far as I could tell, 
>> there is no way 
>> to parameterize the regexp within the fileset, so that does not work.  
>> 
>> Jan.Materne@rzf.fin-nrw.de writes:  
>> 
>> > Have you tried 
>> http://ant.apache.org/manual/CoreTypes/selectors.html#regexpselect ?
>> > Then you got the 'problem' of correctly masking the regexp. 
>> > 
>> > Jan 
>> > 
>> >> -----Urspr√ľngliche Nachricht-----
>> >> Von: msorens@softhome.net [mailto:msorens@softhome.net] 
>> >> Gesendet: Dienstag, 20. Mai 2008 07:57
>> >> An: user@ant.apache.org
>> >> Betreff: generate file list with parameterized regexp 
>> >> 
>> >> 
>> >> I am ant-challenged today: I want to find a set of files in a 
>> >> tree matching 
>> >> a given regular expression. The catch is that the regexp is 
>> >> not constant, 
>> >> but is a function of the file name. I have tried permutations of 
>> >> pathconvert, for loops, and loadfile, filterchain, and 
>> >> linecontainsregexp, 
>> >> stumbling when I could not change the property loaded from 
>> >> loadfile after 
>> >> its initial value. Any suggestions?  

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message