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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:40:28+00:00 2026-06-10T04:40:28+00:00

Why doesn’t the following change the text for me in Android? String content =

  • 0

Why doesn’t the following change the text for me in Android?

String content = "test\n=test=\ntest";
content = content.replaceAll("^=(.+)=$", "<size:large>$1</size:large>")

It returns the original value with no changes. I would expect it to replace the middle =test= with <size:large>test</size:large>

What am I missing here?

Edit: Okay, I understand why ^ and $ don’t work. The point is that I need something that matches text both at the beginning and end of a line, e.g. a line that contains only “=some text=”. Most of the answers given aren’t sufficient, for the following reasons:

=(.+)= doesn’t have anything to do with line endings, so matches any line with two = in it that are not side by side.

.*=(.+)=.* matches the whole line, but has the same problem as the previous

\n=(.+)=\n gets closer, but won’t match two lines in a row (e.g. test\n=test=\n=test=\ntest) It also won’t match an instance on the first or last line

(?<=\n)=(.+)=(?=\n) almost works, but again won’t match an instance on the first or last line

(?<!.)=(.+)=(?!.) is the only one that seems will actually match every line that starts and ends with =, for example, but $1 contains both the replacement and the original string.

content = content.replaceAll("(?<=(\n|^))=(.+)=(?=(\n|$))", "<size:large>$2</size:large>"); is the only answer that seems to actually do what it should.

  • 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-10T04:40:30+00:00Added an answer on June 10, 2026 at 4:40 am

    Your original regex works fine if you turn on multiline mode, using (?m):

    content = content.replaceAll("(?m)^=(.+)=$", "<size:large>$1</size:large>");
    

    Now ^ and $ do indeed match at line boundaries.

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

Sidebar

Related Questions

Why doesn't client validation work? <script src=<%: Url.Content(~/Scripts/jquery-1.4.1.min.js)%> type=text/javascript></script> <script src=<%: Url.Content(~/Scripts/MicrosoftAjax.js)%> type=text/javascript></script> <script
This doesn't work: int number = 1; String numberstring = IntToString(number); I get The
Why doesn't this test case work? <?php // cards with cyrillic inidices and suits
For some reason, after submitting a string like this Jack’s Spindle from a text
Why doesn't this work: <Style TargetType=s:Substance> <Setter Property=Template> <Setter.Value> <DataTemplate> <StackPanel> <TextBlock Text={TemplateBinding Name}/>
This doesn't work: $to = 'myemail@gmail.com'; $from = 'test@test.com'; $subj = 'test'; $message =
Why doesn't this code work? I'am using FF. <head> <script type=text/javascript> document.getElementById(someID).onclick = function(){
Why doesn't the following doesn't handle the exception that was rethrown? I tried all
This doesn't seem to work: NSString *string = [[NSString alloc] init]; string = @%@M,
Doesn't work with other modules, but to give an example. I installed Text::CSV_XS with

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.