I'm a little confused. I thought function (and custom function) support
was added to NAnt 0.85? And if that's true, then why not use
string::replace()? At least for this simple example of changing '.' to
'_' string::replace() would work perfectly well.


--
Edwin G. Castro
Firing Systems Engineer
[EMAIL PROTECTED]
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Cole
Sent: Thursday, September 02, 2004 7:06 AM
To: 'Shawn Haigh'
Cc: [EMAIL PROTECTED]
Subject: RE: [Nant-users] using <regex> task on files

Shawn,
   Here is my custom action and an example build file.  Is this what
your looking for?  pSearch is a regular expression.

-------------------------------------------------------------
<project name="UtilityCenter" default="test">  <script language="C#"
prefix="regex">
  <code><![CDATA[
   [Function("replace")]
   public static string RegexReplace(string pSource, string pSearch,
string
pReplace) 
   {
    System.Text.RegularExpressions.Regex re = new
System.Text.RegularExpressions.Regex(pSearch,
System.Text.RegularExpressions.RegexOptions.Singleline);
    return re.Replace(pSource, pReplace);
   }
  ]]></code>
 </script>
 
 <target name="test">
  <echo message="${regex::replace('1.0.562.2', '\.', '_')}"/>  </target>

</project>
-------------------------------------------------------------

John Cole
-----Original Message-----
From: Shawn Haigh [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 02, 2004 8:43 AM
To: John Cole
Subject: RE: [Nant-users] using <regex> task on files


John

I came across your post and it looks like your custom function could
help me in what I would like to do. Since I am a bit new to custom
functions in nant I was wondering if you could give ma a simple example
of how to use your regex::replace function in a task.

All I want to do is take a property string containing text like;
"1.0.562.2"
and change it to "1_0_562_2".  

ThanX

Shawn 

-------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager. This message contains confidential information and is
intended only for the individual named. If you are not the named
addressee you should not disseminate, distribute or copy this e-mail.


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java
Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id808&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to