ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <mil...@gmx.de>
Subject Re: propertyregex question
Date Wed, 23 Jun 2010 10:30:01 GMT
Andy2008 schrieb am 22.06.2010 um 17:17 (-0700):
> 
> Here's my input
> 
> abc/long/distance
> 
> I want to get abc back.  Here's my code
> 
> <propertyregex property="myprop"
>               input="${input}"
>               regexp="(.*)/*"
>               select="\0"
>               casesensitive="false" />
> 
> but I got back the whole string (abc/long/distance)
> 
> Do you have any ideas?

Yes. You appear to be using a mixture of regular expressions,
as in "(.*)", and shell patterns, as in "/*". Your first group
*greedily* (terminus technicus) captures the entire string until
the end of the line. You'd probably benefit from reading up on
Java regular expression syntax.

<project>
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <property name="input" value="abc/long/distance"/>
  <echo message="${input}"/>
  <propertyregex property="myprop" input="${input}"
    regexp="([^/]+)" select="\0" casesensitive="false" />
  <echo message="${myprop}"/>
</project>

-- 
Michael Ludwig

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


Mime
View raw message