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 8415355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:25:24+00:00 2026-06-10T01:25:24+00:00

I can’t find the way to remove a space using ant. (I don’t mean

  • 0

I can’t find the way to remove a space using ant. (I don’t mean trim, but removing from ~ to )

I want to make one project a little difference from another project.

For example:

I have below code.

.... doSomeThing;

//#removeStart

NotReleasedObject nro = new NotReleasedObject();
nro.doSomeThing();

//removeEnd#

....doAnyThing..

as you can see easily, I want to remove from //#removeStart to //removeEnd#. I’m not sure how much code will be written, but all code inside these 2 tags need to be gone.And there can be multiple //#removeStart ... //removeEnd# in one java file.

Here is my test replaceregexp code:

<replaceregexp flags="s" replace="" byline="false" encoding="utf-8">
        <regexp pattern="//#removeStart.*//removeEnd#"/>
        <fileset dir="${extern-source-path}"/>
</replaceregexp>

------ source for victim.

//#removeStart
space 1
//removeEnd#

something

//#removeStart
space 2
//removeEnd#

Now my code is not working properly.The flag -s works, but if one file has more than 1 match, then everything from space 1 to space 2 is gone. ( including something!)
What I actually want is space 1,2 gone, but something should be left as it is.

How can I fix it so that it replaces each occurrence 1 by 1 ?

  • 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-10T01:25:25+00:00Added an answer on June 10, 2026 at 1:25 am

    Your explicit characters don’t match: your regex says //##ExternRemove whereas your actual text is either //##removeStart or //#removeStart. If that’s an actual regex, the explicit characters need to be exactly the same. Also . doesn’t match newlines, you’d need to include that specifically (e.g. [\s\S]*).

    Finally, you should make the matching non-greedy if you might have multiple pairs of this match (often this is by adding ?). Taken together, you’d probably want a regular expression like:

    //##?removeStart[\s\S]*?//removeEnd##?
    

    That’s assuming you want to allow 1-2 # to start a line and that the phrase will always be removeStart/removeEnd. Otherwise you could add options, e.g.

    //##?(?:removeStart|ExternRemove)[\s\S]*?//(?:removeEnd|ExternEnd)##?
    

    again, this depends on the ant terminology for non-capturing matches.

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

Sidebar

Related Questions

Can PHP PDO extension bind nested objects automatically ? I mean using foreign key
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can I order my users in the database, so I don't have to say
Can I authenticate with just Google account username and password instead of using OAuth?
Can anyone enlighten me to a way I can Highlight the content of an
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want to count how many characters a certain string has in PHP, but
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can't figure out how to do this in a pretty way : I have
Can't work out a way to make an array of buttons in android. This

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.