You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by hi...@accenture.com on 2005/08/02 17:17:30 UTC

Another Problem with a regular expression


Hello;
it's me again.
i tought everything was fine but then i saw strange problem with my propertyregexp usage.
my snippet is:
<propertyregex property="some.name" override="true" input="${some.input}" regexp="([0-9A-Z\/\.a-z]+)" replace="${some.dir}\1" global="true"/>

some.dir being an absolute windows directory: c:\foo\bar\dude
some.input being a relative directory= /some/other/directory
when i run this i get as a result:
C\:foobardude/some/other/directory

with allthe "\" removed from some.dir.

Any clue?
(i tried to add the backslach in regexp but it does not change anything...)



Hind Lwahhabi.



-----Original Message-----
From: hind.lwahhabi@accenture.com [mailto:hind.lwahhabi@accenture.com]
Sent: Tue 8/2/2005 4:36 PM
To: user@ant.apache.org
Cc: antuser@gmail.com
Subject: FW: regular expression help+tokens instead of words
 


Hind Lwahhabi.



-----Original Message-----
From: Lwahhabi, Hind
Sent: Tue 8/2/2005 4:34 PM
To: Ant Users List Patrick Martin
Subject: RE: regular expression help+tokens instead of words
 

no because the line does not start with a blank.
thanks anyway:)
i have solved my problem(see my previous mail) with regexp="([0-9A-Z\/\.a-z]+)" replace="myPrefix\1"

Hind Lwahhabi.




-----Original Message-----
From: Patrick Martin [mailto:antuser@gmail.com]
Sent: Tue 8/2/2005 4:32 PM
To: Ant Users List
Subject: Re: regular expression help+tokens instead of words
 
Hi,

You could try to replace the blank character by ' myPrefix' (not the
blank before myPrefix).

 <propertyregex property="regexp.name"
               input="Foo Bar Blah Blah"
               regexp=" "
               replace=" myPrefix"
               global="true"
               casesensitive="false" />

Patrick Martin

On 8/2/05, hind.lwahhabi@accenture.com <hi...@accenture.com> wrote:
> thanks Ahmed it works for the sample string i provided.
> My question is how can you avoid special characters e.g instead of Foo Bar blabla , you have:
> input string=foo/bar.ext  foo/some1.ext.
> The goal is to match the tokens separated by blank space and not words.
> 
> Thanks for any help!
> 
> 
> Hind Lwahhabi.
> 
> 
> 
> 
> -----Original Message-----
> From: Basel Ahmed [mailto:Basel.Ahmed@fds.com]
> Sent: Tue 8/2/2005 3:42 PM
> To: Ant Users List
> Cc: user@ant.apache.org
> Subject: RE: regular expression help
> 
> Here's a code snippet that does what you'd like to do with
> <propertyregexp>.
> 
> <propertyregex property="regexp.name"
>               input="Foo Bar Blah Blah"
>               regexp="([A-Za-z]+)"
>               replace="myPrefix\1"
>               global="true"
>               casesensitive="false" />
> 
> 
> The result is:
>      [echo]  Regular expression is: myPrefixFoo myPrefixFoo myPrefixFoo
> myPrefixFoo
> 
> Basel Ahmed
> Federated Systems Group
> Site Build & Launch (Duluth)
> basel.ahmed@fds.com
> 678-474-3203
> 
> 
> "Time is the coin of your life. It is the only coin you have and only you
> can determine how it will be spent. Be careful, lest you let others spend
> it for you." --Rod McKuen
> 
> 
> "Live as if your were to die tomorrow. Learn as if you were to live
> forever. " -- Mahatma Gandhi
> 
> 
> "Don't argue for other people's weaknesses. Don't argue for your own. When
> you make a mistake, admit it, correct it, and learn from it--immediately."
> -- Stephen Covey
> 
> 
> 
>              <hind.lwahhabi@ac
>              centure.com>
>                                                                         To
>              08/02/2005 09:21          <us...@ant.apache.org>
>              AM                                                         cc
> 
>                                                                    Subject
>              Please respond to         RE: regular expression help
>              "Ant Users List"
>              <user@ant.apache.
>                    org>
> 
> 
> 
> 
> 
> 
> 
> 
> Do you mean:
> <propertyregexp property="testprefix"  regexp="\w*" replace="myPrefix"/>
> But then all the words would be replaced by the prefix , no?
> Forgive me i ama beginner in regular expressions:)
> 
> 
> Hind Lwahhabi.
> Accenture Belgium - Financial Services & Insurance
> Koningstraat 145 Rue Royale, B-1000 Brussels, Belgium
> mobile: +32 499567544
> phone: + 32 2 226 75 44
> E-mail:hind.lwahhabi@accenture.com
> 
> 
> 
> -----Original Message-----
> From: James Fuller [mailto:jim.fuller@ruminate.co.uk]
> Sent: Tue 8/2/2005 3:11 PM
> To: Ant Users List
> Subject: Re: regular expression help
> 
> hind.lwahhabi@accenture.com wrote:
> 
> >Hello guys;
> >I would like some help for the following.
> >Using <propertyregexp> how would you perform the following:
> >
> >input string="Foo Bar Jeff Blabla"
> >replacing prefix="myPrefix"
> >result string="myPrefixFoo myPrefixBar myPrefixJeff myPrefixBlabla"
> >
> >
>  \w* should match every word or u could use the ^ method.
> 
> 
> I normally use something like this to match words
> /\b([A-Za-z]+)\b
> 
> 
> gl, Jim Fuller
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information.  If you have
> received it in error, please notify the sender immediately and delete the
> original.  Any other use of the email by you is prohibited.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>

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











This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

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




This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.


Re: Another Problem with a regular expression

Posted by Gisbert Amm <gi...@webde-ag.de>.
You need to escape the backslashes, see e.g. 
http://www.regular-expressions.info/java.html

Regards,
Gisbert Amm

hind.lwahhabi@accenture.com wrote:
> 
> Hello;
> it's me again.
> i tought everything was fine but then i saw strange problem with my propertyregexp usage.
> my snippet is:
> <propertyregex property="some.name" override="true" input="${some.input}" regexp="([0-9A-Z\/\.a-z]+)" replace="${some.dir}\1" global="true"/>
> 
> some.dir being an absolute windows directory: c:\foo\bar\dude
> some.input being a relative directory= /some/other/directory
> when i run this i get as a result:
> C\:foobardude/some/other/directory
> 
> with allthe "\" removed from some.dir.
> 
> Any clue?
> (i tried to add the backslach in regexp but it does not change anything...)
> 
> 
> 
> Hind Lwahhabi.
> 
> 
> 
> -----Original Message-----
> From: hind.lwahhabi@accenture.com [mailto:hind.lwahhabi@accenture.com]
> Sent: Tue 8/2/2005 4:36 PM
> To: user@ant.apache.org
> Cc: antuser@gmail.com
> Subject: FW: regular expression help+tokens instead of words
>  
> 
> 
> Hind Lwahhabi.
> 
> 
> 
> -----Original Message-----
> From: Lwahhabi, Hind
> Sent: Tue 8/2/2005 4:34 PM
> To: Ant Users List Patrick Martin
> Subject: RE: regular expression help+tokens instead of words
>  
> 
> no because the line does not start with a blank.
> thanks anyway:)
> i have solved my problem(see my previous mail) with regexp="([0-9A-Z\/\.a-z]+)" replace="myPrefix\1"
> 
> Hind Lwahhabi.
> 
> 
> 
> 
> -----Original Message-----
> From: Patrick Martin [mailto:antuser@gmail.com]
> Sent: Tue 8/2/2005 4:32 PM
> To: Ant Users List
> Subject: Re: regular expression help+tokens instead of words
>  
> Hi,
> 
> You could try to replace the blank character by ' myPrefix' (not the
> blank before myPrefix).
> 
>  <propertyregex property="regexp.name"
>                input="Foo Bar Blah Blah"
>                regexp=" "
>                replace=" myPrefix"
>                global="true"
>                casesensitive="false" />
> 
> Patrick Martin
> 
> On 8/2/05, hind.lwahhabi@accenture.com <hi...@accenture.com> wrote:
> 
>>thanks Ahmed it works for the sample string i provided.
>>My question is how can you avoid special characters e.g instead of Foo Bar blabla , you have:
>>input string=foo/bar.ext  foo/some1.ext.
>>The goal is to match the tokens separated by blank space and not words.
>>
>>Thanks for any help!
>>
>>
>>Hind Lwahhabi.
>>
>>
>>
>>
>>-----Original Message-----
>>From: Basel Ahmed [mailto:Basel.Ahmed@fds.com]
>>Sent: Tue 8/2/2005 3:42 PM
>>To: Ant Users List
>>Cc: user@ant.apache.org
>>Subject: RE: regular expression help
>>
>>Here's a code snippet that does what you'd like to do with
>><propertyregexp>.
>>
>><propertyregex property="regexp.name"
>>              input="Foo Bar Blah Blah"
>>              regexp="([A-Za-z]+)"
>>              replace="myPrefix\1"
>>              global="true"
>>              casesensitive="false" />
>>
>>
>>The result is:
>>     [echo]  Regular expression is: myPrefixFoo myPrefixFoo myPrefixFoo
>>myPrefixFoo
>>
>>Basel Ahmed
>>Federated Systems Group
>>Site Build & Launch (Duluth)
>>basel.ahmed@fds.com
>>678-474-3203
>>
>>
>>"Time is the coin of your life. It is the only coin you have and only you
>>can determine how it will be spent. Be careful, lest you let others spend
>>it for you." --Rod McKuen
>>
>>
>>"Live as if your were to die tomorrow. Learn as if you were to live
>>forever. " -- Mahatma Gandhi
>>
>>
>>"Don't argue for other people's weaknesses. Don't argue for your own. When
>>you make a mistake, admit it, correct it, and learn from it--immediately."
>>-- Stephen Covey
>>
>>
>>
>>             <hind.lwahhabi@ac
>>             centure.com>
>>                                                                        To
>>             08/02/2005 09:21          <us...@ant.apache.org>
>>             AM                                                         cc
>>
>>                                                                   Subject
>>             Please respond to         RE: regular expression help
>>             "Ant Users List"
>>             <user@ant.apache.
>>                   org>
>>
>>
>>
>>
>>
>>
>>
>>
>>Do you mean:
>><propertyregexp property="testprefix"  regexp="\w*" replace="myPrefix"/>
>>But then all the words would be replaced by the prefix , no?
>>Forgive me i ama beginner in regular expressions:)
>>
>>
>>Hind Lwahhabi.
>>Accenture Belgium - Financial Services & Insurance
>>Koningstraat 145 Rue Royale, B-1000 Brussels, Belgium
>>mobile: +32 499567544
>>phone: + 32 2 226 75 44
>>E-mail:hind.lwahhabi@accenture.com
>>
>>
>>
>>-----Original Message-----
>>From: James Fuller [mailto:jim.fuller@ruminate.co.uk]
>>Sent: Tue 8/2/2005 3:11 PM
>>To: Ant Users List
>>Subject: Re: regular expression help
>>
>>hind.lwahhabi@accenture.com wrote:
>>
>>
>>>Hello guys;
>>>I would like some help for the following.
>>>Using <propertyregexp> how would you perform the following:
>>>
>>>input string="Foo Bar Jeff Blabla"
>>>replacing prefix="myPrefix"
>>>result string="myPrefixFoo myPrefixBar myPrefixJeff myPrefixBlabla"
>>>
>>>
>>
>> \w* should match every word or u could use the ^ method.
>>
>>
>>I normally use something like this to match words
>>/\b([A-Za-z]+)\b
>>
>>
>>gl, Jim Fuller
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>>
>>This message is for the designated recipient only and may contain
>>privileged, proprietary, or otherwise private information.  If you have
>>received it in error, please notify the sender immediately and delete the
>>original.  Any other use of the email by you is prohibited.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>>
>>This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

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