ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Finger" <>
Subject RE: replaceregexp help
Date Wed, 25 Jun 2003 23:39:21 GMT
Thanks for the response, glad to know it's just not my rusty regexp skills....
It turns out using match".:(\\*)blah" works, 
I was trying it before I put in the 'i' flag...
I'm still having problems with the replace c:\\\\ though, but there are some bugs and patches
in ant bugzilla, so I'll try those. 
What wierd is I got replace c:\\\\blah to go to --> c:\blah on the write, 
but when I use a property, match="${prop} where prop=c:\\\\\\\\blah
I just get c:blah.....
In the first case I figure ant is preprocessing and then the regexp is getting processed....
In the case with properties, who knows.....

	-----Original Message----- 
	From: Harkness, David [] 
	Sent: Wed 6/25/2003 4:03 PM 
	To: Ant Users List 
	Subject: RE: replaceregexp help

	Assuming the replaceregexp task uses mostly regular expressions (I
	haven't used it, but I'm fairly fluent with regexps), what's happening
	is that \ is escaping the next character (so if you wanted to match a
	real asterisk, you'd do "\*"). Try these:
	Each \\ becomes a single literal \ and ? means zero or one of the
	previous character/group. So that matches \ and \\ but not \\\.
	What's odd is that ".:(\\*)blah" should have matched c:\blah and
	c:\\blah (and c:\\\\\\blah). It's possible that the regexps that task is
	using doesn't have grouping with ()s. In any case, grouping isn't needed
	here as you're modifying a single character (\\ becomes a single \).
	Now for replacing, you need the same escaping:
	Again, it's odd that you're getting "d:localblah" as you should have
	gotten "d:\localblah". It's as if the escape substitution is happening
	  "d:\\localblah" --> "d:\localblah" --> "d:localblah"
	as "\l" will be substituted with "l". If the above doesn't work, see if
	it is doing substitution twice by double all of the "\"s. :) That would
	be odd, however.
	Good luck!
	David Harkness
	Sony Pictures Digital Networks
	-----Original Message-----
	From: Michael Finger []
	Sent: Wednesday, June 25, 2003 3:44 PM
	To: Ant Users List
	Subject: replaceregexp help
	I'm struggling a bit with the replaceregexp task. I have a property file
	want to replace "c:\\blah" in the line
	"myproperty=c:\\blah\\yadaa\\yack" with
	"d:\\localblah" ...
	Here's what i'm doing:
	<replaceregexp file="${veritySearchDir}/config/"
	but I'm getting:
	myproperty=d:localblah\\yadaa\\yack  in the file...
	and I want myproperty=d:\localblah\\yadaa\\yack  in the file...
	I've also tried using @#x5c;...
	Also, on the match part it would be nice to match c:\\blah and c:\blah.
	I've tried match= ".:(\\*)blah" but it doesn't seem to work.
	I'm using ant 1.53 and jdk 1.4.1_02
	To unsubscribe, e-mail:
	For additional commands, e-mail:

View raw message