Hi,

The string::* functions include starts-with, contains, ends-with etc,
but there is no simple "regex" method.

I've scripted a custom function in my buildfile:

<script language="C#" prefix="mwj">
        <references>
          <include name="System.Text.RegularExpressions.dll" />
        </references>
        <imports>
          <import namespace="System.Text.RegularExpressions" />
        </imports>
        <code>
            <![CDATA[
            [Function("regex")]
            public static bool regex(String strIn, String strPattern)
            {
              Regex r = new Regex(strPattern);
              return r.IsMatch(strIn);
            }
            ]]>
        </code>
      </script>

However, I then get:

[script] scanning assembly "blah" for extensions.

Message and my build time has gone from a few seconds to 200+ seconds
for a very simple test of the mwj:regex function. The build that this
will be part of will be pretty big and long and slow, so I'm concious
that such a tiny function adding a few minutes to the build is not
good.

Yes, I could write a proper function extension, but, then I'd have to
make sure that is deployed to all NAnt users building this project.
Which isn't good.

Is there a feature I've missed? Or, is there any chance of getting
something like this checked into CVS?

I'm using it as follows (greatly simplified):
<foreach item="Line" in="./changes/resultsofhugesqljob.txt"
property="currentLine">
        <echo message="Failed to compile ${lines.currentchange}."
if="${mwj::regex(currentLine, '/Msg.*, Level.*, State.*, Server.*,
Line.*/')}" />
</foreach>

-- 
Michael Jervis
[EMAIL PROTECTED]
504B03041400000008008F846431E3543A820800000006000000060000007765
62676F642B4F4D4ACF4F0100504B010214001400000008008F846431E3543A82
0800000006000000060000000000000000002000000000000000776562676F64
504B05060000000001000100340000002C0000000000

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to