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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:36:15+00:00 2026-05-27T01:36:15+00:00

I have a FileInputStream who reads a file which somewhere contains a string subset

  • 0

I have a FileInputStream who reads a file which somewhere contains a string subset looking like:

...
    OperatorSpecific(XXX)
    {
       Customer(someContent)
       SaveImage()
       {
...

I would like to identify the Customer(someContent) part of the string and switch the someContent inside the parenthesis for something else.

someContent will be a dynamic parameter and will contain a string of maybe 5-10 chars.

I have used regEx before, like once or twice, but I feel that in a context such as this where I don’t know what value will be inside the parenthesis I’m at a loss of how I should express it…

In summary I want to have a string returned to me which has my someContent value inside the Customer-parenthesis.

Does anyone have any bright ideas of how to get this done?

  • 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-27T01:36:16+00:00Added an answer on May 27, 2026 at 1:36 am

    Try this one (double the escaping backslashes for the use in java!)

    (?<=Customer\()[^\)]*
    

    And replace with your content.

    See it here at Regexr

    (?<=Customer\() is look behind assertion. It checks at every position if there is a “Customer(” on the left, if yes it matches on the right all characters that are not a “)” with the [^\)]*, this is then the part that will be replaced.

    Some working java code

    Pattern p = Pattern.compile("(?<=Customer\\()[^\\)]*");
    String original = "Customer(someContent)";
    String Replacement = "NewContent";
    
    Matcher m = p.matcher(original);
    String result = m.replaceAll(Replacement);
    
    System.out.println(result);
    

    This will print

    Customer(NewContent)

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

Sidebar

Related Questions

I have a file that contains java serialized objects like Vector. I have stored
I have a file in Java FileInputStream in = null; try{ in = new
I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
I have a text file in my computer which I am reading form my
I have a property file which is inside a default package and the class
I have a .properties file, who has this format : toto=titi fofo=fifi coco=cici mama=momo
I have this ArrayList files for(File file : files){ InputStream in = FileInputStream(file); //
I have a filename in my code as : String NAME_OF_FILE=//sdcard//imageq.png; FileInputStream fis =this.openFileInput(NAME_OF_FILE);
we have a piece of code which generates a zip file on our system.
I have a multipart format text file. i am going threw the file looking

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.