ReplaceAll() single quotes to double quotes
i've been trying to use the replaceAll() method to change single
quotes in a document to double quotes. All my attempts have
failed.
Thanks in advance,
Enaknonnel
Sorry, I was terse in my first post, but since you are just replacing one char
with another, using replaceAll is overkill -- it is meant to take a regular expression
search string. So keep it simple and use replace. I think you may have
chosen replaceAll because of that reassuring "All" in its name, but do check
the API: method replace replaces all occurrences.
One more thing: posting something like "All my attempts have failed" is itself
a failure. It tells us nothing concrete. A better post would have included
a short example program that was your best attempt.
Similar Messages
-
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
inidajava.lang.String.replace () will not work to replace quote with double quote.Really?
String x = ...
x.replace( "'", "\"" ); -
What 's the difference between quote ' and double quote "?
what's the difference between quote' and double quote "?
when we use each one?
Exemple of use of each case?'c' is a char, ie. a primitive type representing a single character
"c" is an instance of the String class length 1. -
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 ones.replaceAll("'","\"");{code}
or just one of the String#replace() methods.
Edited by: sabre150 on Mar 17, 2009 11:48 AM -
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. -
Change XML declaration from single quote to double quote
Hi all,
i have the following problem in my File Receiver Adapter. My XML File has the declaration <?xml version='1.0' encoding='utf-8'?> (With single quotes ') and want to change it to <?xml version="1.0" encoding="utf-8" ?> (With double quotes ")
I use the XMLAnonymizerBean but this does not change the XML declaration.
Any ideas how to change the declaration
Thanks MaxHi Suraj,
on the Modul Tab i have the following:
1 | AF_Modules/XMLAnonymizerBean | Local Enterprise Bean | Anonymizer
2 | CallSapAdapter | Local Enterprise Bean | 0
Anonymizer | anonymizer.acceptNamespaces | http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Aviso_V1.0 ns0 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoHeader ns1 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoShipper ns2
Anonymizer | anonymizer.quote | "
That is all what i have on the module tab.
I send the data as Text (not Binär). Thats all what i have in the adapter. Do you need any further information?
Regards, Max -
SQL Loader: double quotes inside double quotes
Hello,
I need to find a solution for loading some data that contains double quotas. The csv contains data like:
"1";"Name1";"Name2"
"2";"Name3 "another thing here"";"Name4"
"3";"Name33 "thing here"";"Name "name" Name"
The data inside the " " must be loaded exactly as it is, that means that in the DB, for row2, column2 the data must be: Name3 "another thing here". I cannot remove the qoutes.
the CTL:
LOAD DATA
CHARACTERSET AL32UTF8
INTO table table_name
APPEND
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
TRAILING NULLCOLS
Column1,
Column2,
Column3
Could anyone help on this?try with this ctl
LOAD DATA
CHARACTERSET AL32UTF8
INTO table table_name
APPEND
FIELDS TERMINATED BY ';' ENCLOSED BY '"'
TRAILING NULLCOLS
Column1,
Column2,
Column3
)also refer to
here and here
for detailed explanations and instructions -
PL/SQL: quoting problems (double quotes within PL/SQL, howto?)
Hello,
I have a big problem with that: I just cannot use execute immediate to do what I want.
The goal is that another user than sysdba needs to be able to open/close the wallet (we are sysdba and our client doesn't want us to be able to open the wallet, and we don't want the client to have sysdba), so I take advantage of the fact that procedures are executed by default with the privileges of the user which writes it. So, I try and create a PL/SQL procedure as sys and grant execute rights to the client user.
To open/close a wallet, the command is:
alter system set encryption wallet open/close identified by "thepasshere";
Note the double quotes... They are the problem here (passwords are mixed case and contain special characters). Right now, the only solution I came up with is:
create or replace procedure open_wallet (passwd in varchar2) is
begin
execute immediate 'alter system set encryption wallet open identified by "' || passwd || '";';
end;
But that's vulnerable to code injection... So, instead, I tried:
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar2(512);
begin
cmd != 'alter system set encryption wallet open identified by ":1"';
execute immediate cmd using passwd;
end;
which yields "ORA-00911: invalid character" - uh?
Now, if I try:
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar(512);
begin
cmd := 'alter system set encryption wallet open identified by :1;';
execute immediate cmd using passwd;
end;
it answers "ORA-28357: password required to open the wallet"
Aaargh! I see no way around that :(
Is there a solution at all?Did you try including the double quotes in the password bind value? Either when you pass the value in or by adding it in the routine.
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar(512);
pass varchar(512);
begin
cmd := 'alter system set encryption wallet open identified by :1;';
pass := '"' || passwd || '"';
execute immediate cmd using pass;
end; -
To display combination of single quotes and double quotes in textfield
please send the code
Do this:
//put this into the head section
<head>
<script language="JavaScript">
<!--
function input(value){
document.getElementById('textfield').value = value;
//-->
</script>
</head>
//put this into the body section
<body>
<input type="text" name="textfield" id=textfield value="">
<br>
input quotes for whatever reason
</body>
//read the following tread:
http://forum.java.sun.com/thread.jsp?forum=45&thread=136985 -
I'm looking for a GREP (or maybe a script) which can change the single quotes to double quotes, but taking into account that French (and Dutch) have a lot of single quotes that don't have to be converted (collega's; l'enfant;d'été...). The idea is that some people use the single quotes in stead of the double ones ('lorem ipsum daedalus inter e d'été', etc). the quote before lorem has to be changed, not the ' after the letter d, and the ' after été has to be changed too.
Any suggestions?This seems to work:
'(?![\l\u])|(?<![\l\u])'
For my test, I turned all found items to red. -
I have been trying to figure out my problem for several hours, but still didn't get it. Hope to get an idea from you guys. My code is as follows:
var astr;
var outCr ="|";
var outLf = "\u0000";
var cr = "\n";
var lf ="\r";
var ddQuote=""";
var dtQuote='\"';
astr = "<%=firstDesc%>";
astr.replace(outCr,cr);
astr.replace(outLf,lf);
astr.replace(ddQuote, dtQuote);
while (astr.indexOf(outCr) > 0) {
z = astr.indexOf(outCr);
astr = astr.substring(0, z) + cr + astr.substring(z+1,astr.length );
while (astr.indexOf(outLf) > 0) {
z = astr.indexOf(outLf);
astr = astr.substring(0, z) + lf + astr.substring(z+1,astr.length );
while (astr.indexOf(ddQuote) > 0) {
z = astr.indexOf(ddQuote);
astr = astr.substring(0, z) dtQuote astr.substring(z+1,astr.length );
document.form1.description.value=astr;
The value of firstDesc is a very big string from the database that contains carriage return, linefeed, single quote and double quote. It needs to be displayed in a HTML text area. Now everything works fine except the double quote. A firstDesc value containing double quote will not appear in the text area, and it even stop my jsp page and disable other buttons. But if I get rid of the code handling the double quote, everything works fine. What's the problem?maybe you should ask this question in a JavaScript forum.
-
Can't import csv fields starting with double quotes but lack ending ones
Hi all,
When I'm trying to used external table to import a csv file, specified as using comma as delimiter optionally enclosed by double quotes, some records are rejected because a field in the record has starting double quotes, but without ending ones.
Assume the customer really want these starting double quotes, how do I change my external table specification such that these starting double quotes are treated as part of the field data and can be successfully inserted into db?
Many thanks.I have no access to Oracle during weekends, so nothing can be tested. So here it goes:
Suggestion: DELIMITED BY '","' and of course omitt ENCLOSED BY '"'
You will have to update each row of the rows just loaded setting the first_field to substr(first_field,2) and the last_field to substr(last_field,-2)
If all the fields are not enclosed in double quotes (TRUE for strings and FALSE for numbers and dates) the situation (syntax diagrams allow two delimiters only) is somehow more complicated, anyway you can specify DELIMITED BY ',' and update all varchar2 fields in each row of the rows just loaded setting the varchar2_field to substr(varchar2_field,2,length(varchar2_field) - 2).
Regards
Etbin
After posting I noticed it's difficult to distinguish between single and double quotes:
the first DELIMITED BY should read {single quote){double quote}{comma}{double quote}{single quote)
the ENCLOSED BY should read {single quote){double quote}{single quote)
Message was edited by: Etbin
user596003 -
SSRS Report Returning Double Quote string from a Single Quote String
Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote.
For example following string:
'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
Returns:
''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
through SSRS report.
Here is the split function Im using in a report.
CREATE Function [dbo].[fnSplit] (
@List varchar(8000),
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY ,
Item varchar(8000) NULL
As
Begin
Declare @item varchar(4000),
@iPos int
Set @Delimiter = ISNULL(@Delimiter, ';' )
Set @List = RTrim(LTrim(@List))
-- check for final delimiter
If Right( @List, 1 ) <> @Delimiter -- append final delimiter
Select @List = @List + @Delimiter -- get position of first element
Select @iPos = Charindex( @Delimiter, @List, 1 )
While @iPos > 0
Begin
-- get item
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) )
If @@ERROR <> 0 Break -- remove item form list
Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 )
If @@ERROR <> 0 Break -- insert item
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break
-- get position pf next item
Select @iPos = Charindex( @Delimiter, @List, 1 )
If @@ERROR <> 0 Break
End
Return
End
FYI: I'm getting @List value from a table and passing it as a string to split function.
Any help would be appreciated!
ZKAnother user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
AS
BEGIN
WHILE CHARINDEX(@delim,@string) > 0
BEGIN
INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
END
INSERT INTO @result (value) VALUES (@string)
RETURN
END
GO
ZK -
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
Maybe you are looking for
-
Hi Myself and my brother have been sharing the same apple id for all the itunes purchases. We both have iphone 4. Since the introduction of icloud, we are little confused about the id managing process. Yesterday, we both updated our iOS to iOS 5. And
-
i keep getting this message http://i43.tinypic.com/2rqj23l.jpg i have downloaded the 64 one. i'm unsure what i have to do, any advice woud be great as i cannot use my iphone as i need to sync it! Thanks
-
My iMac (late 2010 model) desktop's hard drive is fried (was about 200GB). How much am I expecting to pay for a new one and retrieve my information?
-
WRT1900AC and Macbook Pro Retina - refuses to connect with Wireless N
I have the first generation Macbook Pro Retina, and just recently upgraded my D-Link D-655 for the Linksys WRT1900AC. I also put the router on the first floor (the D-Link was in the basement) because there were some huge holes in wireless coverage I
-
IMac 24": crash/unbootable after airport express 2007-001 update
My iMac 24" (2.33GHz, Nvidia 7600GS) crashed when applying the update listed at http://www.apple.com/support/downloads/airportextremeupdate2007001.html Video became corrupted, and underneath the garbled sceen appeared the grey "restart your computer"