Thanks Scot!
On Jan 20, 2010, at 7:47 PM, "Scot P. Floess" <sflo...@nc.rr.com> wrote: Yeah, I'll give it some thought and see if there is something I can think of tomorrow as well :) On Wed, 20 Jan 2010, Eric Fetzer wrote: I tried this Scot, but it didn't do it. So here's an easy repro: <project default="main"> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <property name="myProp" value="C:\myDog\Loves\Big\Juicy\Bones"/> <target name="main"> <propertyregex property="tmpProp" input="${myProp}" override="true" regexp="\\" replace="\\\\" global="true"/> <echo message="tmpProp is: ${tmpProp}"/> </target> </project> It produces: [echo] tmpProp is: C:\myDog\Loves\Big\Juicy\Bones If I change it to: <project default="main"> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <property name="myProp" value="C:\myDog\Loves\Big\Juicy\Bones"/> <target name="main"> <propertyregex property="tmpProp" input="${myProp}" override="true" regexp="\" replace="\\" global="true"/> <echo message="tmpProp is: ${tmpProp}"/> </target> </project> it crashes with: java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1650) at java.util.regex.Pattern.compile(Pattern.java:1403) at java.util.regex.Pattern.<init>(Pattern.java:1124) at java.util.regex.Pattern.compile(Pattern.java:840) at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.getCompiledPatter n(Jdk14RegexpMatcher.java:67) at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.matches(Jdk14Rege xpMatcher.java:94) at net.sf.antcontrib.property.RegexTask.doReplace(RegexTask.java:135) at net.sf.antcontrib.property.RegexTask.execute(RegexTask.java:192) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav a:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe cutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) I don't know that what we're trying to do is possible with propertyregex. It seems it may need some scripting. All I'm really trying to do is: if(property1.indexOf(string1) >= 0) then return true; I'll take a look at how to achieve this tomorrow. Thanks! Eric ________________________________ From: Scot P. Floess <sflo...@nc.rr.com> To: Ant Users List <user@ant.apache.org> Sent: Wed, January 20, 2010 2:21:41 PM Subject: Re: AppendToProperty MacroDef Mmm - you may need to do this before your first propertyregex <propertyregex property="tmpProp" input="${propertyList}" override="true" regexp="\\" replace="\\\\" globale="true"/> Basically the above will escape the \ On Wed, 20 Jan 2010, Eric Fetzer wrote: Well, out of that error and on to the next. It seems that PropertyRegEx has an issue with the "\" as well. I wrote a different macrodef that works without slashes, but not with slashes. Anyone see a better way? <macrodef name="md.isInPropList" description="Find if a dir is a subdir of any dir in the list"> <attribute name="var.item"/> <attribute name="var.itemList"/> <sequential> <!--First get rid of any values left from previous calls to this md and set to false--> <unset name="isInList"/> <property name="isInList" value="false"/> <!--For loop on each item in itemlist to see if any of them are true--> <for list="@{var.itemList}" param="item"> <sequential> <!--Make sure regExResult isn't left over--> <unset name="regExResult"/> <!--Regex expression that will result in the value if it is in there--> <propertyregex property="regExResult" input="${propertyList}" override="true" regexp=".*(@{item})" select="\1" casesensitive="false" /> <!--If regExResult is set to the value of the item, we have a match--> <if> <equals arg1="${regExResult}" arg2="${item}"/> <then> <unset name="isInList"/> <property name="isInList" value="true"/> </then> </if> </sequential> </for> </sequential> </macrodef> Thanks, Eric ________________________________ From: Eric Fetzer <elstonk...@yahoo.com> To: Ant Users List <user@ant.apache.org> Sent: Wed, January 20, 2010 1:40:34 PM Subject: Re: AppendToProperty MacroDef Beautiful, thanks Scott! On Jan 20, 2010, at 1:18 PM, "Scot P. Floess" <sflo...@nc.rr.com> wrote: You could use Ant Contrib's var task - probably be a little easier :) <macrodef name="md.AppendProperty"> <attribute name="var.propertyName"/> <attribute name="var.stringAppend"/> <sequential> <var name="@{var.propertyName}" value="$...@{var.propertyname}}@{var.stringAppend}"/> </sequential> </macrodef> On Wed, 20 Jan 2010, Eric Fetzer wrote: Hi all. I wrote a MacroDef to append a string to a property. All works as planned until you slip a "\" in there and then it gets jacked up. My javascripting has MUCH to be desired. Any help? <macrodef name="md.AppendProperty"> <attribute name="var.propertyName"/> <attribute name="var.stringAppend"/> <sequential> <script language="javascript"> <![CDATA[ curVal=project.getProperty("@{var.propertyName}"); project.setProperty("@{var.propertyName}",curVal+"@{var.stringAppend}"); ]]> </script> </sequential> </macrodef> Thanks, Eric Scot P. Floess 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-890-8117 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org Scot P. Floess 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-890-8117 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org Scot P. Floess 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-890-8117 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org