Replace Single Quote with double quote

Hi All,
I have a String s="help'me'to'replace";
i want to replace single quote( ' ) in to double quote ( " )
The final out put should be like this help"me"to"replace
( Actually this string i have to pass in to an XML )
Please help any one

s.replaceAll("'","\"");{code}
or just one of the String#replace() methods.
Edited by: sabre150 on Mar 17, 2009 11:48 AM                                                                                                                                                                                                                                                               

Similar Messages

  • How do I replace quotation marks with double angle quotation marks, still keeping the word in the mi

    Hi,
    Does anyone know how to replace quotation marks with double angle quotation marks, still keeping the word in the middle?
    For example: I search for a word with quotation marks by typing in: (")(\w+)(") in the "find what" field. What should I type in the "change to" field?
    I'd be very grateful for answers!

    It's much simpler: find " and replace with " (make sure that 'Use typographer's quotes' is enabled in the preferences).
    Peter

  • How to replace single backslash(\) to double backslash(\\)

    Hi
    I want to replace single backslash to double backslash from the string.
    Code is here
    String data="File name :\n.txt;File name:\t.txt";               
    data = data.replace("\\","\\\\");
    System.out.println("-->" +data);
    i tried to this code but its not working. Help me if anyone is know.
    Please reply me asap.
    Thanks

    DVekaria wrote:
    Are you not getting my question.Obviously not. That's why we've asked you to clarify it. Twice, at least.
    whatever data contenting in Variable, it must print as its on the screen.This code does that.
    String s = "a\nb\tc;"
    System.out.println(s);The variable s contains a reference to a String object. That String object holds 5 characters: 'a', newline, 'b', tab, 'c'. The println prints out exactly what's in that String--those 5 characters. Note that there is not even one single backslash in that String.
    a
    b cThis is exactly what you asked for.
    Now let's say I create a file in Notepad, and I type the following, and then save it:
    a\nb\tcThat file contains 7 characters. 'a', '\', 'n', 'b', '\', 't', 'c'. If I read that file with Buffered reader, it will give me a String object with those same 7 charcters. If I print it out it will print out those 7 characters.
    a\nb\tcNote that in both cases, I am printing out exactly what is in the String.
    Think carefully on what is the same and what is different between those two cases, and use it to form a clearer definition of your problem. Remember, we want to know what you're trying to accomplish. Just saying "I want to replace backslashes" tells us how you're trying to solve your problem.

  • How to replace single quote with double quote

    hai all,
    i have a problem,
    i am trying insert a string containing single quote into ms-access database.
    it is giving error.
    how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
    insert into database.
    in java.lang.String
    replace () will not work to replace quote with double quote.
    any otherway to solve this problem.
    please mail me to [email protected]
    thank you
    sambareddy
    inida

    java.lang.String.replace () will not work to replace quote with double quote.Really?
    String x = ...
    x.replace( "'", "\"" );

  • SQL Injection, replace single quote with two single quotes?

    Is replacing a single quote with two single quotes adequate
    for eliminating
    SQL injection attacks? This article (
    http://www.devguru.com/features/kb/kb100206.asp
    ) offers that advice, and it
    enabled me to allow users to search name fields in the
    database that contain
    single quotes.
    I was advised to use "Paramaterized SQL" in an earlier post,
    but I can't
    understand the concept behind that method, and whether it
    applies to
    queries, writes, or both.

    Then you can use both stored procedures and prepared
    statements.
    Both provide better protection than simply replacing
    apostrophes.
    Prepared statements are simple:
    Set myCommand = Server.CreateObject("ADODB.Command")
    ...snip...
    myCommand.CommandText = "INSERT INTO Users([Name], [Email])
    VALUES (?, ?)"
    ...snip...
    myCommand.Parameters.Append
    myCommand.CreateParameter("@Name",200,1,50,Name)
    myCommand.Parameters.Append
    myCommand.CreateParameter("@Email",200,1,50,Email)
    myCommand.Execute ,,128 'the ,,128 sets execution flags that
    tell ADO not to
    look for rows to be returned. This saves the expense of
    creating a
    recordset object you don't need.
    Stored procedures are executed in a similar manner. DW can
    help you with a
    stored procedure through the "Command (Stored Procedure)"
    server behavior.
    You can see a full example of a prepared statement by looking
    at DW's
    recordset code after you've created a recordset using version
    8.02.
    "Mike Z" <[email protected]> wrote in message
    news:eo5idq$3qr$[email protected]..
    >I should have repeated this, I am using VBScript in ASP,
    with an Access DB.
    >

  • Replace single quotes

    I know that I have to trap the single quotes when inserting names, streets, etc.
    I tried to use replace() and to replace the single ones with 2 singles. Could somebody help me with the syntax as I'm getting all the time errors. Here is the code:
    Insert into t1 values(Last_name, First_name, Street)
    Last_name = 'last_Name's+app', First_name = first_name's_app', Street = 'street's_app'
    Insert into t1 values((Replace(last_name, ','')), (replace(First_name,',''),(replace(Street,','')))
    Also, do I need to worry when I passing the single quotes to the calling program?
    Thanks a lot.
    MJ

    Check this out.
    SQL> desc mytable
    Name                                      Null?    Type
    COL1                                               VARCHAR2(20)
    COL2                                               NUMBER(2)
    SQL> insert into mytable values('last_name''s+app',1);
    1 row created.
    SQL> select * from mytable;
    COL1                       COL2
    last_name's+app               1

  • Replace single quote with two single quotes

    Hi all,
    I have a value = ABCD'S(>@!23. i want to replace the value as ABCD''S(>@!23.
    Thanks in advance

    What is your database version ? Q operator works from 10G onwards.
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 23 14:35:38 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    SQL> conn hr
    Enter password:
    Connected.
    SQL>  CREATE TABLE test_Q_operator(str VARCHAR2(30));
    Table created.
    SQL> INSERT INTO test_Q_operator VALUES('ABCD''S(>@!23');
    1 row created.
    SQL> INSERT INTO test_Q_operator VALUES('Saubhik''s test row');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT str,REPLACE(str,Q'[']',Q'['']') col2
      2  FROM test_Q_operator;
    STR
    COL2
    ABCD'S(>@!23
    ABCD''S(>@!23
    Saubhik's test row
    Saubhik''s test row
    SQL>Also check you SQL*PLUS client version.

  • Replaceing single quote in error message

    Hi,
    Iam trying following to get and insert into ERROR_LOG table:-
    SUBSTR('<%=odiRef.getPrevStepLog("MESSAGE")%>',1,1000)
    It is throwing up an error when it is trying to insert into ERROR_LOG Table,the reason is error message has got following :-
    ' PLS-00201: identifier 'III_1742_2013011901' must be declared'
    i.e quote with in a quote if i take that one out from error message i can insert into ERROR LOG Table.
    How can we avoid this in ODI odiRef.getPrevStepLog message?
    Cheers

    try to replace the character or read after PLS.
    You can give a try like below. This should be done inside script let.
    odiRef.getPrevStepLog("MESSAGE").replace("'","")

  • Replacing single quote

    I am an ASP developer and new to JSP. I want to know that how we can replace a singlequote( ' ) in a string, like we do by "replace" function in ASP.

    What do you mean by replacing the (') if you want to use the (') or (") in the String then you can use
    \" or \'

  • How to replace single font with combined font quickly in Framemaker 12

    Why there is no combined font can be selected in "Replace With" field?

    Yes, but some one Has been achieved
    only haveProvided a illustrate
    http://images.missyuan.com/attachments/day_131226/20131226_705ae5b52765c61bdfa18FN2NfkOUbU n.gif
    I  did not understand, why fonts management  did not like the indesign, They are all belong to adobe

  • How to use a single quote string in where condition

    Hi,
    I have one problem in building a query.
    SELECT agx_drug_indication.record_id, agx_drug_indication.fk_ad_rec_id,
    agx_drug_indication.drugindicationmeddraver, agx_drug.record_id,
    agx_drug.fk_apat_rec_id,
    REPLACE (agx_drug.medicinalproduct, '''', '''') AS "MEDICINALPRODUCT",
    pack_imp_objects.fn_get_arisg_code
    (147,
    agx_drug_indication.drugindicationmeddraver
    ) AS "DRUGINDICATIONMEDDRAVER",
    agx_drug.drugindication,
    NVL (agx_drug.drugcharacterization, 1) AS "DRUGCHARACTERIZATION",
    agx_safety_report.record_id, agx_safety_report.case_identifier_no,
    agx_safety_report.fk_apat_rec_id,
    pack_imp_objects.fn_meddra_llt_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver,
    1
    ) AS "LLT_CODE",
    pack_imp_objects.fn_meddra_soccode_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "PRIMARY_SOC_CODE",
    pack_imp_objects.fn_meddra_soccode_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "CASE_SOC_CODE",
    pack_imp_objects.fn_meddra_pt_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "PT_CODE",
    pack_imp_objects.fn_get_aer_id (11) AS "AER_ID"
    FROM agx_drug_indication,
    agx_drug,
    agx_safety_report
    WHERE agx_drug_indication.fk_ad_rec_id = agx_drug.record_id
    AND agx_drug.fk_apat_rec_id = agx_safety_report.fk_apat_rec_id
    AND agx_safety_report.case_identifier_no IS NOT NULL
    AND agx_drug_indication.drugindication IS NOT NULL
    AND agx_drug.medicinalproduct =
    REPLACE ('*-qVAGX_DRUG.MEDICINALPRODUCT*', '''', '''')
    In the above query last line '-qVAGX_DRUG.MEDICINALPRODUCT' is a dynamic variable which may or may not contain the single quotes.
    Ex: ABC's or just ABC.
    The query has to support both single quote and without quote in it.
    I wanted everything to be done in the sinlq query on not a PL/SQL Block.
    Please help me ASAP

    kumar0828 wrote:
    <font color="#FF0000"> ... </font>
    REPLACE (agx_drug.medicinalproduct, '''', '''') AS "MEDICINALPRODUCT",
    <font color="#FF0000"> ... </font> <pre>
    REPLACE (agx_drug.medicinalproduct, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    With the above statement you are replacing single quote with another single quote
    (which is nonsense).
    <font color="#FF0000"> ... </font>
    AND agx_drug.medicinalproduct = REPLACE ('*-qVAGX_DRUG.MEDICINALPRODUCT*', '''', '''')
    In the above query last line '-qVAGX_DRUG.MEDICINALPRODUCT' is a dynamic variable which may or may not contain the single quotes.This is not a dynamic variable but a string value:
    <pre>
    AND agx_drug.medicinalproduct =
    REPLACE (<font style="background-color: #FF3D55">'*</font>-qVAGX_DRUG.MEDICINALPRODUCT<font style="background-color: #FF3D55">*'</font>, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    *-qVAGX_DRUG.MEDICINALPRODUCT* <pre>
    AND agx_drug.medicinalproduct =
    REPLACE (<font style="background-color: #FF3D55">q'*</font>-qVAGX_DRUG.MEDICINALPRODUCT<font style="background-color: #FF3D55">*'</font>, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    -qVAGX_DRUG.MEDICINALPRODUCT q'[a]' => a
    q'[a']' => a'
    q'[a'']' => a''
    q'*a*' => a
    q'*a'*' => a'
    q'*a''*' => a''
    A variable also cannot contain a dot (.):
    <pre>VAGX_DRUG<font style="background-color: #FF3D55">.</font>MEDICINALPRODUCT</pre>
    Ex: ABC's or just ABC.
    The query has to support both single quote and without quote in it.
    I wanted everything to be done in the sinlq query on not a PL/SQL Block.
    Please help me ASAPTry this:
    <pre>
    AND agx_drug.medicinalproduct = MY_VARIABLE
    </pre>

  • Single slash to Double Slash Convertion

    hi all,
    i want to replace single slash (\) by double slash(
    ) in a path , ex :
    ...\..\.. should become
    ..   when i m trying to do so,it takes it as an escape sequence character. Can anyone help me plz

    Use double-slash to represent the single slash and a quadruple slash to represent the double-slash.
    stringreplace( Transaction.PropertyName , "
    Above statement translates to replace "\" with "
    " when the expression in the Link Editor is evaluated.
    The other option is to create a local property called Slash with a default value of \ in the property editor.
    Your expression would look like:
    stringreplace( Transaction.PropertyName , Local.Slash , Local.Slash & Local.Slash )
    Of course, you could use another local property of double-slash if you wish.
    Hope this helps.
    Cheers,
    Jai.

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Replacing " (double quote) with ' (single quote)

    Hi there,
    I have the following method to manipulate user input. All I want to do is, to replace the double quote with a single quote. The implementation I tried was,
    this.replace(desc, "\"", "'");
    This does not work for me. It jsut removes the double quote and does not introduces the single quote. Could any one please advise?
    Thanks,
    Des
    public static String replace(String line, String oldString, String newString) {
              if(line != null && oldString != null && newString != null) {
                   int index = 0;
                   while ((index = line.indexOf(oldString, index)) >= 0) {
                        line = line.substring(0, index) +
                             newString +
                             line.substring(index + oldString.length());
                        index += newString.length();
              return line;
         }

    Bad luck.. I am unable to get it still.
    This is the code I am using (implemetation is in a JSP. I am using this code to test it).
    public class Test{
    public static void main(String args[]){
         String s = args[0];
         Test t = new Test();
         String doubleQuote = "\"";
         System.out.println(" output :"+ t.replace(s,doubleQuote,"'"));
         //System.out.println(" output :"+ t.replace(s,"\"","'"));
         //System.out.println(" output :"+ t.replace('"', '\''));
    public static String replace(String line, String oldString, String newString) {
              if(line != null && oldString != null && newString != null) {
                   int index = 0;
                   while ((index = line.indexOf(oldString, index)) >= 0) {
                             System.out.println(" line count :");
                        line = line.substring(0, index) +
                             newString +
                             line.substring(index + oldString.length());
                        index += newString.length();
              return line;
    }mshn02
    The main problem is I am stuck with the server's version of Java (which I have no control on it). I could not use 1.4.2

  • Firefox is replacing double quotes with single quotes.

    In WordPress and at other sites where I input and save text, Firefox is replacing double quotes with single quotes when I save. It's also showing double quotes as single quotes on websites. I tried uninstalling and reinstalling, and it's still happening.

    Do you have the needed font installed?
    *http://en.wikipedia.org/wiki/Punctuation

Maybe you are looking for