in Education by
I have a string like (&(objectclass=${abc})(uid=${xyz})) How can I search ${abc} and ${xyz} and replace with another strings. There can be any number of occurence of such substrings i.e.${abc} in main string. I was thinking of string.indexOf( but that could be messy. Any best approach? ${abc} will be replaced by another string abc. I will get them from some other parameters. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You need to escape special characters ($ , { , } ). Try this: str.replaceAll("\\$\\{abc\\}","abc"); This can be weird but can help you out: str = str.substring(str.indexOf("${")+2, str.indexOf("}")) This will work for all (any number of) strings between ${ and }.

Related questions

0 votes
    I have a string like (&(objectclass=${abc})(uid=${xyz})) How can I search ${abc} and $ ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a string like (&(objectclass=${abc})(uid=${xyz})) How can I search ${abc} and $ ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a string like (&(objectclass=${abc})(uid=${xyz})) How can I search ${abc} and $ ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I want to find out if a given String 'b' matches the pattern of String 'a'. Furthermore, the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I want to find out if a given String 'b' matches the pattern of String 'a'. Furthermore, the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Write a program to accept string from user and search a given character from string without using find() function Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    I use the query below: update ACCOUNT_EXTERNAL_IDS set EXTERNAL_ID = 'username:vietnt' where ACCOUNT_ID='1000000' ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    A………………….. is a special type of website that allows us to search for documents, websites over the internet Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    One character cannot use ziplines whike their special ability is activated in apex legends wo it is? A-Caustic ... -Gibraltar D-Wraith Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    ________ Injection attack is a special attack done through character elements Carriage Return or Line Feed. ... -Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    In the code below, in "parse" function I am trying to get substring from the string "line". I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    In the code below, in "parse" function I am trying to get substring from the string "line". I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    Can someone tell me any string.contains or string.indexof method in Python I want to do if not somestring.contains("boom"): continue Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I have the below string "Halo Device ANumber : 6232123123 Customer ID : 16926" I want to search with the ... 22 substring : Device Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    Which of this method of class String is used to extract a substring from a String object? (a) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
...