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

Similar Messages

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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

  • Loading csv file trying to replace double quotes

    Hi, I am trying to load a csv file with a field with double qoutes that I want to replace the double qoutes to one. The CSV file I will enter
    "TEST,2345" in a field and when it loads its as ""TEST,2345""
    So I got this code to handle it.
    Pattern quotesRegex = Pattern.compile("\"\"");
              Matcher m = fieldRegex.matcher(line);
              while (m.find()) {
                   String field;
                   if (m.group(1) != null) {
                        // If a quoted string was matched replace escaped double quote,
                        // "" with "
                        field = quotesRegex.matcher(m.group(1)).replaceAll("\"");
    else {
                        field = m.group(2);
                   fields.add(field.trim());
    I want to change a line like this
    D,,""TEST,2345"",46,,
    to
    D,,"TEST,2345",46,,
    but afterwards nothing has changed the record looks as below
    D,,""TEST,2345"",46,,
    Whats wrong with this?
    thanks

    I simply created a simple csv file with one field that I entered a double qoute of "TEST,2345"
    Later when reading in the file(using the code I pasted in) I can inspect it and its """TEST,2345"""
    The relaceAll doesnt seem to change anything(nor did my code). So I was stumped. thanks

  • Replacing inconsistant spacing with single space in a string

    is it possible to replace multiple spaces within a string with one space only. Number of spaces is different all the time.
    say one field contains strings with imbedded spaces
    I need to replace all these values so that there will be only one space between words.
    For Eg.
    Input                             Expected Result
    aaa    bbb                       aaa bbb
    ww                vv             ww vv
    ww ss      kk                    ww ss kk
    [/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    user11253970 wrote:
    I am in Oracle 9i :( I can not use reg exp
    Assuming strings do not contain CHR(0) (character with ascii code 0):
    SQL> SELECT  'aaa          bbb  aaa bbb' str,
      2          replace(replace(replace('aaa          bbb  aaa bbb',' ',' ' || CHR(0)),CHR(0) || ' '),CHR(0)) new_str
      3    FROM  dual
      4  /
    STR                                 NEW_STR
    aaa          bbb  aaa bbb           aaa bbb aaa bbb
    SQL> SY.

  • ACS - Replace IP Subnet with Single IP's

    Hi Everyone,
    I have been charged with a task to create individual entries in our ACS for each of our network devices. I am new to the ACS and the documentation does not seem to cover this scenario. Right now we have all our devices fall under a single subnet.
    When I try to create a device within the subnet, it tells me IP subnets overlap with those defined for device.
    If I try to change the existing IP Subnet to an IP range so I can exclude some devices from the IP Subnet, it tells me I cannot switch from IP Mask mode to IP Range mode.
    I am guessing I need to delete the the record for the IP subnet and add each device back individually. My concern is that none of my devices will work until I add each one back.
    Is this correct or is there a better way to go about this?
    Thanks,
    DC

    You can configure the default network device with the same settings ad your subnet, remove the subnet definition and re-add the hosts one by one. You can also use file import to reduce time.
    Sent from Cisco Technical Support Android App

  • Replace characters between with single * in variable

    Hi Experts ,
    I want to replace all characters between <  > with *. Data is stored in variable type char255.
    Example ,
    Suppose variable contains : Wage Type <Wage Type> Not Valid For Interface ID <ID>
    I want output as Wage Type * Not Valid For Interface ID *.
    Thanks & Regards ,
    Jigar Thakkar

    Hi Jigar,
    Find the length of the string and use DO...ENDDO statement. Inside the loop, didnt consider the text between < and > and move to another string and add * when  > is encountered in the string.
    data:
      gv_len type i,
      gv_str type string value 'Wage Type <Wage Type> Not Valid For Interface ID <ID>',
      gv_rep_str type string,
      gv_flag type char1,
      gv_index type sy-index.
    gv_len = strlen( gv_str ).
    do gv_len times.
    gv_index = sy-index - 1.
    if gv_str+gv_index(1) = '<'.
    gv_flag = 'X'.
    continue.
    elseif gv_str+gv_index(1) = '>'.
    clear gv_flag.
    concatenate gv_rep_str '*' into gv_rep_str.
    continue.
    elseif gv_flag is initial.
    concatenate gv_rep_str gv_str+gv_index(1) into gv_rep_str.
    endif.
    enddo.
    write:/ gv_rep_str.
    Thanks,
    Vinay
    Edited by: Vinaykumar G on May 29, 2009 8:04 PM

  • Replacing multiple nodes with single node in OSB

    Hi,
    I have a case where I will get a xml like below:
    <LINEITEMS>
         <LINE_ITEM>
              <LINE_ITEMNO>1</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE1</MESSAGE>
         </LINE_ITEM>
         <LINE_ITEM>
              <LINE_ITEMNO>3</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE3</MESSAGE>
         </LINE_ITEM>
         <LINE_ITEM>
              <LINE_ITEMNO>1</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE2</MESSAGE>
         </LINE_ITEM>
         <LINE_ITEM>
              <LINE_ITEMNO>3</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE4</MESSAGE>
         </LINE_ITEM>
    <LINE_ITEM>
              <LINE_ITEMNO>2</LINE_ITEMNO>
              <STATUS_CODE>1</STATUS_CODE>
              <MESSAGE>MESSAGE5</MESSAGE>
         </LINE_ITEM>
    </LINEITEMS>
    I need to make this as below:
    <LINEITEMS>
         <LINE_ITEM>
              <LINE_ITEMNO>1</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE1;MESSAGE2</MESSAGE>
         </LINE_ITEM>
         <LINE_ITEM>
              <LINE_ITEMNO>3</LINE_ITEMNO>
              <STATUS_CODE>0</STATUS_CODE>
              <MESSAGE>MESSAGE3;MESSAGE4</MESSAGE>
         </LINE_ITEM>
    <LINE_ITEM>
              <LINE_ITEMNO>2</LINE_ITEMNO>
              <STATUS_CODE>1</STATUS_CODE>
              <MESSAGE>MESSAGE5</MESSAGE>
         </LINE_ITEM>
    </LINEITEMS>
    I need to have only one entry for each line Item.
    Please let me know on the approach on how to do it in OSB.
    Thanks

    You can try this :-
    let $out:= <LINEITEMS>{ for $x in 1 to count($input/LINE_ITEM)
                                  let $LineItme := $input/LINE_ITEM[$x]/LINE_ITEMNO
                             let $match:= for $y in $x to count($input/LINE_ITEM)
                                  where $input/LINE_ITEM[$y]/LINE_ITEMNO= $LineItme
                                  return $input/LINE_ITEM[$y]/MESSAGE
                                  return
                                  <LINE_ITEM>
                                       <LINE_ITEMNO>{$LineItme/text()}</LINE_ITEMNO>
                                       <STATUS_CODE>{data($input/LINE_ITEM[$x]/STATUS_CODE)}</STATUS_CODE>
                                       <MESSAGE>{fn:data($match)}</MESSAGE>
                                  </LINE_ITEM>
    }</LINEITEMS>
    return $out
    You many then have to remove duplicates with line items. use fn:distinct() and then loop through.

  • Replacing many spaces with single space in a string

    Hi!
    I have the following strings:
    "Eric       B"
    "John                 A"
    "Mary Anne   C"But I want them to be like this:
    "Eric B"
    "John A"
    "Mary Anne C"Do anyone have an idea how to do this?
    Edited by: suladna on Aug 2, 2008 5:42 AM

    Use this:
    String s = "Mary    Anne   C";
    System.out.println(s.replaceAll("\\s+", " "));Edited by: prigas on Aug 2, 2008 6:15 AM

  • 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( "'", "\"" );

  • 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                                                                                                                                                                                                                                                               

  • Double Quotes In LOV Return Value Being Replaced With &qu ot; By APEX 4

    My company recently upgraded our development and test boxes to APEX 4.0.2, which we have been wanting for a while now. We discovered that since the upgrade some of our checkboxes and radio groups no longer work as expected. What I mean by this is that the return values being checked for were not correct, and on several occasions we received PL/SQL errors related to numeric to character conversion issues.
    After debugging some it turns out that we have the following LOV query for one of our Checkboxes:
    select
    statement d,
    stmt_id || '" title="&P20_FORM_STMT. ' || statement || '.' r
    from
    stmts
    The return value for the LOV is setup so that it would return a 508 compliant checkbox. We were told we needed a title for each value of a checkbox or radio group to be 508 compliant. These titles must also be relevant to the selection being made, hence the substitution string being used in the return value.
    What I discovered in all of this is that APEX 3.2 did not convert the double quotes in our return value to &qu ot;, but APEX 4.0.2 does. This causes the value of any given checkbox or radio group to look like the following:
    value="1&qu ot; title=&qu ot;This is the statement that I have made."
    And what we are looking for, and what APEX used to do is this:
    value="1" title="This is the statement that I have made."
    Does anyone know a way to prevent APEX from converting the double quotes to &qu ot;, or is there a way to insert an element attribute for each checkbox or radio group value that contains a substitution string?
    Thanks in advance!
    Pastey

    ryansun wrote:
    4.2.1
    Hi,
    I have a classic report, which has a count column that is hyperlinked. using the standard apex column hyperlink option. In that we have the option of passing values. I noticed that when I am passing a value which has "/" in it, it replaces the / with & #x2F;
    I have created a application item which I am populating with the report column.
    Because of which I cannot use that value in the report query.
    Any suggestions?Yes. Don't pass string values in URLs. Especially where it is possible for these strings to contain URI reserved or APEX sensitive characters. This might work for a while but your application can be broken months from now by users including a "&" or ":" in data that gets passed as a URL parameter. Whilst it is possible to escape strings to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Exposing data in the URL may also introduce security vulnerabilities. Also note that the maximum length of a URL in Microsoft Internet Explorer is about 2KB, which can easily be exceeded by throwing a few string values at it.
    Only use discrete alphanumeric key values as URL parameters. In target pages/regions, use these key values to retrieve the required data using item source attributes and processes.

  • How to replace one double quotes with two double quotes in XSLT

    How can I replace one double quote to a two double quote in a string in XSLT
    I am passing the parameter string to XSLT template contains the value as
    <xsl:variable name="Description">Hi! "How are you</xsl:variable>
    <xsl:variable name="VQuotes">""</xsl:variable>
    I nead the output as
    Hi! ""How are you.
    Tried with Translate function, but it did not work out
    <xsl:element name="DESCRIPTION_SHORT">
              <xsl:value-of select="translate($Description,'&quot;', VQuotes)" />
            </xsl:element>But it is giving the same result as Hi! "How are you
    When I tried with
    <xsl:element name="DESCRIPTION_SHORT">
              <xsl:value-of select="translate($Description,'&quot;', 'BB')" />
            </xsl:element>
    It gave the result as
    Hi! BHow are you.
    It is replacing only one character with one. how to make it for two characters.
    Am I doing anything wrong in syntax?
    Please help.
    Regards, Vignesh S

    Hi Vignesh,
    Try this.
    Its a two step process:
    Step1: Add the following template would be "called" to do the replacement as your want:
    <xsl:template name="string-replace-all">
    <xsl:param name="text" />
    <xsl:param name="replace" />
    <xsl:param name="by" />
    <xsl:choose>
    <xsl:when test="contains($text, $replace)">
    <xsl:value-of select="substring-before($text,$replace)" />
    <xsl:value-of select="$by" />
    <xsl:call-template name="string-replace-all">
    <xsl:with-param name="text"
    select="substring-after($text,$replace)" />
    <xsl:with-param name="replace" select="$replace" />
    <xsl:with-param name="by" select="$by" />
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$text" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Step2: Call the above templeate in the place where you want to call, like this:
    <!--Define the variables-->
    <xsl:variable name="Description">Hi! "How are you</xsl:variable>
    <xsl:variable name="sQuotes">"</xsl:variable>
    <xsl:variable name="VQuotes">""</xsl:variable>
    <!--Following call the template which you have defined in step1-->
    <xsl:element name="DESCRIPTION_SHORT">
    <xsl:variable name="myVar">
    <xsl:call-template name="string-replace-all">
    <xsl:with-param name="text" select="$Description" />
    <xsl:with-param name="replace" select="$sQuotes" />
    <xsl:with-param name="by" select="$VQuotes" />
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="$myVar" />
    </xsl:element>
    I have tested this and works. And outputs as the following with two-double quote as you want.
    <DESCRIPTION_SHORT>Hi!
    ""How are you</DESCRIPTION_SHORT>
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • String value changes single quote ' to double quote "

    I am creating a list with different bill codes within single
    quotes as follows
    <cfset corlist = " '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ' ">
    when I do an output
    for
    <cfoutput>AND idbillcode IN ( #corlist
    #)</cfoutput>
    I get the values as follows
    AND idbillcode IN ( '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ')
    However when I put the same string within a cfquery the
    single quotes get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800 '',''1950 '',''7001 '') which throws an error.
    Anybody has any clues.
    Thanks.

    However when I put the same string within a cfquery the
    single quotes
    get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800
    '',''1950
    '',''7001 '') which throws an error.
    Anybody has any clues.
    That is ColdFusion escaping the single quotes, by doubling
    them so that
    you can search for strings such as "singhpk's code does not
    work".
    (Note the single quote/apostrophe that would normally break
    this string
    if it was not escaped.
    To tell CF not to do this, one uses the
    preserveSingleQuotes() function.
    The documentation has all the details.

  • Double quotes issue with GUI_UPLOAD

    Hello Gurus,
    I'm uploading a tab delimited file from my PC using GUI_UPLOAD. I've a description field (Char 40) in my input file which contains characters like double quotes or commas or single quotes. Whenever there is a comma or a double quote in the desc field in my input file, the field value is uploaded into the program as the actual value with double quotes in front of the value and at the end of the value.
    Say if I'm uploading <b>steel 1"</b>, then it is uploaded into the program as <b>"steel 1""</b>. Any ideas why is this and how to fix it.
    JJ

    Appreciate ur answer Anand. I want to know why I get the value with double quotes in front of it and towards the end of it. I know that I can get rid of the extra double quotes with offsetting and replace statement...Thats not what I was expecting. I want to know why the extra double quotes are coming into the picture.
    FYI, I'm on ECC 6.0 and the snippet of my code is:
      DATA: lv_file TYPE string.
      lv_file = p_file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = lv_file
          filetype            = 'ASC'
          has_field_separator = 'X'
        TABLES
          data_tab            = itab_file.

Maybe you are looking for

  • WHICH IS BETTER! (CASE POLL...please pic

    http://us.creative.com/products/prod...y=27&product=5 <SPAN>[url="http://pdaden.com/shop/cart.php?target=product&action=view&product_id=690 2&substring=zen+micro">http://pdaden.com/shop/cart.php?target=product&action=view&product_id=690 2&substring=z

  • Text file needed for Defor01

    hi,,      i need the text file for (Delfor01)Idoc type. whether its possible to see, if means say me the steps, Or Say the links to refer.. Advance thaks.

  • User deleted from EBP

    Hello Experts, Below is the scenarion: (SRM 4.0 classic) User A created few SCs. Before all the SCs were completed(closed), the User A got deleted from the system Now we recreate USER A with same ID again, and assign him/her to Org. Str. User A, now

  • PLL exception not propagating to form.

    Hello all, I am working in form 10g with database 9i. I am calling one Pll procedure from one trigger and handling the exception in the trigger outblock. But the trigger is not handling in the pll ORA-06502, Numeric or Value error. It is poping up th

  • Why does the download progress and speed in the window constantly freeze?

    Like the question says.. almost every time I download something I don't know if the download is working because the progress will freeze at some point.