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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:08:03+00:00 2026-05-11T04:08:03+00:00

I have to replace the content of this xml string through java <My:tag>value_1 22&#xA;value_2

  • 0

I have to replace the content of this xml string through java

<My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag> 

so, this string has been taken from an xml and when I acquire it I have this result:

<My:tag>value_1 22 value_2 54 value_3 11</My:tag> 

If I try to replace the content by this way:

String regex =  '(<My:tag>)(.*)(</My:tag>)'; String new_string = old_string.replaceAll(regex,'<My:tag> new_stuff </My:tag>'); 

I get no result. I think because of the &#xA; symbol

but if I try to replace the string without the &#xA; symbol, everything goes fine.

Suggestions? Thanks

  • 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. 2026-05-11T04:08:03+00:00Added an answer on May 11, 2026 at 4:08 am

    I’m not 100% sure how the java regex-engine works, but I can’t possibly imagine that an entity would cause your problems. You should first try to simply remove your brackets, since you’re replacing the entire expression, and not extracting anything.

    What might be causing it though is if your entity is actually translated to a new-line, it might be the case that your regex won’t catch it unless you’re explicitly doing a multiline match. You could also try doing

    [.\n]* 

    instead of your

    .* 

    This might be a bid greedy though, and the backtracking to much for the matcher to handle. Unfortunately, I don’t have any java stuff installed on this machine, so I can’t really try it and test it. One other possibility would be to actively look for the next opening angle bracket, like so:

    [^<]*  

    EDIT:
    As you suggested, i tried your link and the following worked perfectly:

    Expression:

    <My:tag>[^<]*</My:tag> 

    Replacement:

    <My:tag> new_stuff </My:tag> 

    Test string:

    <My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer is it this? What about this then... LinqDataSource1.Where = "MyDateColumn… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer Here are some VBScript examples to extract the data you… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer Here is an example (including creating an event) for ASP.NET… May 11, 2026 at 11:34 pm

Related Questions

I am in the middle of making a script for doing translation of xml
I have to invoke a web service with a single parameter, a String in
I have a directory of files for which I'd like to do in-place string
I have created a C# class file by using a XSD-file as an input.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.