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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:46:40+00:00 2026-05-27T20:46:40+00:00

i need to replace Sprite name = new Sprite(number1, number2, this.mScritteRegion.get(number3) { stuff_here };

  • 0

i need to replace

Sprite name = new Sprite(number1, number2, this.mScritteRegion.get(number3)
{
     stuff_here
};

where name, numberX, and stuff_here are a the part i want to keep

with

RectangularShape name = mLanguageManager.getSpriteWithText(number1, number2, 0, 0, "", getResources.getString(R.string.), mLanguageManager.getFont("main_font"), new IOnAreaTouched()
{
      stuff_here
});

So far i managed with regex to find the first part of the code, but i can’t select the new line + { + stuff_here + };

Here the regex

Sprite (\w)* = new Sprite\((\d)*(\s)*,(\s)*(\d)*(\s)*,(\s)*this.mScritteRegion.get\((\d)*\)\)

and what i think i’ll need to use to replce it

RectangularShape $1 = mLanguageManager.getSpriteWithText\($2, $5, 0, 0, "", getResources.getString\(R.string.\), mLanguageManager.getFont\("main_font"\), new IOnAreaTouched\(\) $X\)

i put $X because i still don’t know what index it will be, in addition i don’t know how to handle the }; to });. I must get stuff_here until };, because it is the only delimiter that grants me to catch everything, but i don’t know then how to put the parenthesis in between them..

I just started today looking ad regex, so i’m a total noob in this field..

Can you help me?

  • 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-27T20:46:41+00:00Added an answer on May 27, 2026 at 8:46 pm

    I did this in NetBeans, I figure the regex must look the same, maybe the substitution characters are different (I will check when I have access to a computer with Eclipse).

    The regex to catch your first String is:

    (?s)Sprite (\w+) = new Sprite\((\w+), (\w+),.*?(.\{.*?\});
    

    The substitution regex is

    RectangularShape $1 = mLanguageManager.getSpriteWithText($2, $3, 0, 0, "", getResources.getString(R.string.), mLanguageManager.getFont("main_font"), new IOnAreaTouched()$4);
    

    A few remarks:

    • the (?s) flag means that the dot (.) can be matched to a new line character
    • there is one assumption here: the }; sequence must not appear in the stuff_here block
    • this transformation loses the new line character at the end of the signature – the semantics are the same though, and you can bring it back with formatting templates.

    So, the source being:

    Sprite name = new Sprite(number1, number2, this.mScritteRegion.get(number3)
    {
      stuff_here
    };
    

    I get:

    RectangularShape name = mLanguageManager.getSpriteWithText(number1, number2, 0, 0, "", getResources.getString(R.string.), mLanguageManager.getFont("main_font"), new IOnAreaTouched()   {
             stuff_here
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to replace a domain name on all the links on the page that
need to replace <wiki>this page</wiki> to <a href='wiki/this_page'>this page</a> using callback function: text =
I need to replace imagesrc with the value stored in this object. However when
I need to replace all occurrences with the name that is given by the
I need to replace special characters from a string, like this: this.value = this.value.replace(/\n/g,'');
I need to replace more than 20 000 names with new names i created
I have a string. In this string i need replace all special characters (0-31
I want create Word document from another Word document, but I need replace some
Need to replace colons wherever they're found in specific elements with id's. This works
I need to replace part of a string. I was looking through the Python

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.