Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java how to replace string between 2 character? Example I am given a string, String test = address {address} address2 {address2} I want to

In java how to replace string between 2 character?

Example I am given a string,

String test = "address {address} address2 {address2}"

I want to be able to replace the address between brackets{} to "123 test street" ans address2 between brackets {} to "123 abc street".

Therefore I want the output to be "address 123 test street address2 123 abc street".

I have tried following,

test = test.replace("address", "123 test street")

and

test = test.replace("address2", "123 abc street")

These does not work as I have not specified brackets in anywhere in code and also when I replace the "address", it is also replacing the address in "address2" with the value of address (123 test street), since I have specified address first.

Is there a way I could tell program to change the address and address2 between the brackets only and also not to change "address" in "address2" with the value of address?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

Does the duty to accommodate apply in this case?

Answered: 1 week ago