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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:31:22+00:00 2026-05-14T18:31:22+00:00

Problem: Turn My Testtext TARGETSTRING My Testtext into My Testtext targetstring My Testtext Perl

  • 0

Problem: Turn

"My Testtext TARGETSTRING My Testtext" 

into

"My Testtext targetstring My Testtext"

Perl supports the “\L”-operation which can be used in the replacement-string.

The Pattern-Class does not support this operation:

Perl constructs not supported by this class:
[…]
The preprocessing operations \l \u, \L, and \U.
https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html

  • 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-05-14T18:31:23+00:00Added an answer on May 14, 2026 at 6:31 pm

    You can’t do this in Java regex. You’d have to manually post-process using String.toUpperCase() and toLowerCase() instead.

    Here’s an example of how you use regex to find and capitalize words of length at least 3 in a sentence

        String text = "no way oh my god it cannot be";
        Matcher m = Pattern.compile("\\b\\w{3,}\\b").matcher(text);
    
        StringBuilder sb = new StringBuilder();
        int last = 0;
        while (m.find()) {
            sb.append(text.substring(last, m.start()));
            sb.append(m.group(0).toUpperCase());
            last = m.end();
        }
        sb.append(text.substring(last));
    
        System.out.println(sb.toString());
        // prints "no WAY oh my GOD it CANNOT be"
    

    Note on appendReplacement and appendTail

    Note that the above solution uses substring and manages a tail index, etc. In fact, you can go without these if you use Matcher.appendReplacement and appendTail.

        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            m.appendReplacement(sb, m.group().toUpperCase());
        }
        m.appendTail(sb);
    

    Note how sb is now a StringBuffer instead of StringBuilder. Until Matcher provides StringBuilder overloads, you’re stuck with the slower StringBuffer if you want to use these methods.

    It’s up to you whether the trade-off in less efficiency for higher readability is worth it or not.

    See also

    • StringBuilder and StringBuffer in Java
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Could you not create a custom template for the page? May 16, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer You can change any of the parameters by setting the… May 16, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer I am having trouble coming up with a scenario where… May 16, 2026 at 11:39 pm

Trending Tags

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

Top Members

Related Questions

I am having a little problem how can I turn the following code into
Ive got a problem that if I have a template class, which in turn
When in doubt, turn to Stackoverflow... I'm having a problem with string allocation. My
I'm using this helper method to turn my PartialViewResult into string and returning it
I have a lot of legacy code which I currently compile using an antiquated
Let's say I am defining a browser implementation class for my application: class InternetExplorerBrowser
How do I turn off gzip compression on my SOAP requests from Silverlight 3
I am facing a problem where-in I cannot select videos from the photo album
I'm developing a turn-by-turn navigation software for Windows Mobile using C# and .NET CF.
While trying problem 41 from the Euler Project, I ran across what seems to

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.