String replace

CodeLancer
CodeLancer used Ask the Experts™
on
Hi all,
I am getting one resultset value from query and i assigned it string which have these values
SI_NAME,
SI_ID,
SI_OWNER
SI_STARTTIME

In somecases,any one or more values may missing.
All i need to do is to find the above said values in string and replace with the user defined value.
eg:
SI_NAME="codelancer"
SI_ID="11"
SI_OWNER ="admin"
SI_STARTTIME ="11:45:12"

The important thing here to consider is that order the values assigned in input should be same in output string also i.e

Input String embedname="3&6q=%25SI_NAME%25%25SI_ID%25%25SI_OWNER%25%25SI_STARTTIME%25,0P&6p,0P";

output from string :SI_NAMESI_IDSI_OWNERSI_STARTTIME

final desired output :codelancer11admin11:45:12

Thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
For source String 's' try


        StringBuilder sb = new StringBuilder();
        Pattern p = Pattern.compile("\"(.*?)\"");
        Matcher m = p.matcher(s);

        while (m.find()) {
            sb.append(m.group(1));
        }

        System.out.println(sb.toString());

Open in new window

Author

Commented:
good answer
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial