Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:18:34+00:00 2026-06-07T12:18:34+00:00

I was writing some build scripts for my project. I wanted a regex pattern

  • 0

I was writing some build scripts for my project. I wanted a regex pattern which can match everything before a particular word. For eg: My script looks like this

Create Table ABC(
id int(50)
)

--//@UNDO

Drop table ABC

I want to match everything before –//@UNDO using nant regex task. How do I implement it??

I also want it to match everything in the file if –//@UNDO is not present in the file. I am not getting a way around

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:18:35+00:00Added an answer on June 7, 2026 at 12:18 pm

    This is what I ended up doing

    <loadfile file="${filePathAndName}" property="file.contents" />
        <property name="fileHasUndo" value="${string::index-of(file.contents, '--//@UNDO')}" />
        <choose>
          <when test="${fileHasUndo ==  '-1' }">
              <echo file="${file}" append="true" message="${file.contents}" />
          </when>
          <otherwise>
            <regex pattern="(?'sql'[\s\S]*)--\/\/@UNDO[\s\S]*"  input="${file.contents}" options="Multiline"/>
            <echo file="${file}" append="true" message="${sql}" />
          </otherwise>
        </choose>
    

    I found the index of –//@UNDO. And depending on its presence I am doing a choose when.. Solved the problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing some helper functions for a project im working on. I've always wanted
I am writing some tools for our build system to enforce some strict calling
I'm working on a some build scripts that I'd like to depend on only
I am writing some code in C which connects to MYSQL server. I am
I'm writing a script which pulls out some patient data and generates an XML
I am writing some code which maps LDAP property names to friendly names and
I'm writing a script to remove some build artifacts older than 1 week. The
I'm writing some jquery to programmatically build a list of links and I'd like
Writing some test scripts in IronPython, I want to verify whether a window is
While writing some C code, I decided to compile it to assembly and read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.