You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Z W <mp...@gmail.com> on 2008/03/25 01:24:31 UTC

regular expressions in Ant

Hi

I have trouble converting \ to \\,  for example in
\\filer\Test\PaC\M2\5.3, to   \\\\filer\\Test\\PaC\\M2\\5.3.
I tried with ant-contrib's
	<ac:propertyregex property="html_2"
		  input="${html_1}"
		  regexp="([\]"
		  replace="\\"
		  casesensitive="false"/>

But I get errors
C:\main.xml:452: java.util.regex.PatternSyntaxException: Unclosed
character class near index 3 ([\]


 ^


Thanks for sharing

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


Re: regular expressions in Ant

Posted by Olivier Gies <ol...@bull.net>.
Backslashes in Ant need to be escaped, as in any regular Java String:

         <ac:propertyregex property="html_2"
                   input="${html_1}"
                   regexp="\\"
                   replace="\\\\"
                   casesensitive="false"/>

BR,
Olivier

-------- Original Message  --------
Subject: Re: regular expressions in Ant
From: Z W <mp...@gmail.com>
To: Ant Users List <us...@ant.apache.org>
Date: 25/03/2008 08:35

> I updated with removal of ( from ([\]
> and still get the same error about
> 
> java.util.regex.PatternSyntaxException: Unclosed character class near index 2
> [\]
>   ^
> 
> On Mon, Mar 24, 2008 at 5:24 PM, Z W <mp...@gmail.com> wrote:
>> Hi
>>
>> I have trouble converting \ to \\,  for example in
>> \\filer\Test\PaC\M2\5.3, to   \\\\filer\\Test\\PaC\\M2\\5.3.
>> I tried with ant-contrib's
>>        <ac:propertyregex property="html_2"
>>                  input="${html_1}"
>>                  regexp="([\]"
>>                  replace="\\"
>>                  casesensitive="false"/>
>>
>> But I get errors
>> C:\main.xml:452: java.util.regex.PatternSyntaxException: Unclosed
>> character class near index 3 ([\]
>>
>>
>>  ^
>>
>>
>> Thanks for sharing
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

-- 
*Olivier Gies*

*Delivery Manager
Customs & Tax Software Engineering Center
Bull, Architect of an Open World ^TM
Phone: +86 (10) 65978001 - Ext 555 *

*www.bull.com <http://www.bull.com/>*

*This e-mail contains material that is confidential for the sole use of
the intended recipient. Any review, reliance or distribution by others
or forwarding without express permission is strictly prohibited. If you
are not the intended recipient, please contact the sender and delete all
copies.*


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


RE: regular expressions in Ant

Posted by "Vallon, Justin" <jv...@bear.com>.
[\] is open-character-class right-bracket.  The exception is that you are missing a ']', making the pattern [\]] - matching a single right-bracket.
 
You mean [\\], or more simply \\.
 
To turn backslash into double backslash, try: regexp="\\" replace="\\\\"

	-----Original Message----- 
	From: Z W [mailto:mpc8250@gmail.com] 
	Sent: Mon 2008-03-24 20:34 
	To: Ant Users List 
	Cc: 
	Subject: Re: regular expressions in Ant
	
	

	I updated with removal of ( from ([\] 
	and still get the same error about 

	java.util.regex.PatternSyntaxException: Unclosed character class near index 2 
	[\] 
	  ^ 

	On Mon, Mar 24, 2008 at 5:24 PM, Z W <mp...@gmail.com> wrote: 
	> Hi 
	> 
	> I have trouble converting \ to \\,  for example in 
	> \\filer\Test\PaC\M2\5.3, to   \\\\filer\\Test\\PaC\\M2\\5.3. 
	> I tried with ant-contrib's 
	>        <ac:propertyregex property="html_2" 
	>                  input="${html_1}" 
	>                  regexp="([\]" 
	>                  replace="\\" 
	>                  casesensitive="false"/> 
	> 
	> But I get errors 
	> C:\main.xml:452: java.util.regex.PatternSyntaxException: Unclosed 
	> character class near index 3 ([\] 
	> 
	> 
	>  ^ 
	> 
	> 
	> Thanks for sharing 
	> 

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



***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.
***********************************************************************

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


Re: regular expressions in Ant

Posted by Z W <mp...@gmail.com>.
I updated with removal of ( from ([\]
and still get the same error about

java.util.regex.PatternSyntaxException: Unclosed character class near index 2
[\]
  ^

On Mon, Mar 24, 2008 at 5:24 PM, Z W <mp...@gmail.com> wrote:
> Hi
>
> I have trouble converting \ to \\,  for example in
> \\filer\Test\PaC\M2\5.3, to   \\\\filer\\Test\\PaC\\M2\\5.3.
> I tried with ant-contrib's
>        <ac:propertyregex property="html_2"
>                  input="${html_1}"
>                  regexp="([\]"
>                  replace="\\"
>                  casesensitive="false"/>
>
> But I get errors
> C:\main.xml:452: java.util.regex.PatternSyntaxException: Unclosed
> character class near index 3 ([\]
>
>
>  ^
>
>
> Thanks for sharing
>

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