How do I replace one ' (Single Quote) with '' (Two single Quote)
Hi,
I have been surfing around the forum, coudn't find the similiar case.
I have been trying but fail. Below is my code:
activity = request.getParameter("activity");
activity = activity.replace("\'", "\'\'");
Error Occur:
Incompatible type for method. Can't convert java.lang.String to char. activity = activity.replace("\'", "\'");
I'm trying to use replaceAll(), but seem like the method is not existed, we are using Version Java 1.3
Pls advise.
Regards
Ying
For JDK 1.3 or ealier, use this:
public static String replaceSubstrings(String str, String sub, String rep){
int s, p, q;
int slen = sub.length();
StringBuffer sb = new StringBuffer();
s = 0;
p = str.indexOf(sub);
q = p + slen;
while (p != -1){
sb.append(str.substring(s, p));
sb.append(rep);
s = q;
p = str.indexOf(sub, s);
if (p != -1){
q = p + slen;
sb.append(str.substring(s));
return sb.toString();
activity = replaceSubstrings(activity, "'", "''");
Similar Messages
-
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.
> -
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,'"', 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,'"', '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 SHi 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. -
How do I replace one video file with another
Hey all
I'm new to Imovie, so please bare over with me.
I made a long movie using a MOD format file from my JVC home camera
When I where to convert or burn the movie in Imovie it made an error.
After much trouble I found out that it was the MOD format that was the problem
So I bought an expensive piece of software that converted the MOD file to MOV:
And with a new test project it now works flawless...
Anyways back to the original project and the problem:
- I have now converted the original MOD file to MOV
- I have the original Imovie project with the MOD file.
How do I replace the mod file in the imovie project with the new mov file, while keeping, that is transfering all my work on the mod file over to the new mov file?
Thnx
Kris• In the Layers Panel draw the Layer’s Vector Mask icon onto the trashcan-icon
• move that Layer above the new Text Layer
• invoke Create Clipping Mask (command-alt-G) from Layers Panel’s fly-out menu or alt-click on the line separating the two Layers’ icons -
How do I replace one vector mask with another?
I have a template for a web site that I'm trying to figure out as I learn CS5. The template has a vector mask created out of some writing that was converted into an object/vector mask. I would like to replace with a layer I created that has different writing in it. How would I replace the vector mask in the template with the new object I created?
Thanks for any help you can give.
Best -- Catherine• In the Layers Panel draw the Layer’s Vector Mask icon onto the trashcan-icon
• move that Layer above the new Text Layer
• invoke Create Clipping Mask (command-alt-G) from Layers Panel’s fly-out menu or alt-click on the line separating the two Layers’ icons -
How do i sync one itunes account with two iphones, one ipod touch, and a nano?
I need help in how to sync the one itunes account we use as a family with the two iphones my wife and i have and an ipod touch that my son has and a nano that my daughter has. Please help.
That article applies, as far as I can tell, to all things called iPod X where X can be nano, touch, classic etc.
We don't have two iPhones in the family as yet but as I understand it each device can have separate settings for syncing calendars and contacts. For example my iPhone syncs these over the air with the Exchange server at work so if/when my wife gets an iPhone it would be easy to have hers sync to our computer
To make sure your apps don't inadvertently merge turn off Automatically sync new apps from the apps tab when you connect your device.
The Apple support document How to use multiple iPods with one computer suggests a number of ways for managing the media content. I use method two (Sync with selected playlists) with a slight twist. Rather than regular playlists I set the grouping field to indicate which users should receive which tracks and create smart playlists based on the content of this field.
e.g.
"Alice's Tracks" is "Grouping contains Alice" + "Kind contains audio"
"Bob's Videos" is "Grouping contains Bob" + "Kind does not contain audio"
Tracks that both Alice & Bob want on their iPods have the grouping set to "Alice/Bob"
etc.
I currently manage our family's five iDevices using this system, each getting a different selection to suit their tastes and the capacity of their device. An advantage of using the grouping field is that it is stored in file tags (for non-wav audio files anyway) so that it is relatively easy to recreate the playlists should the iTunes library get trashed and need rebuilding. Also useful if you move files about manually as playlist membership is preserved when you delete & re-import the tracks.
tt2 -
How do I replace multiple consecutive spaces with a single space?
I need to convert any occurrence of multiple consecutive spaces in a string to a single space. How do I create the regex pattern to do that?
r9973 wrote:
Sorry, more like: String test = "Some Text Here"Want to convert to String test = "Some Text Here"
Post the code that you used to test the regex. I just tried it and it worked fine for me. All you need to do is apply the regex replaceall to your string variable that holds the string
String test = "Some Text Here";
test = test.replaceAll(" +", " ");
System.out.println(test);And thats it. -
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 advanceWhat 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. -
How to work on one project but with two different computers
I'm editing a movie.
My computer might be overwhelmed with all the information - speed is slowed and it gets hot quickly.
I would like to use my second computer where I have cloud installed
to edit on the same timeline or in a different sequence to give my
main computer a rest.
Is that possible?
Thank you for your help!As well as the reply from Anish about using your program on 2 computers, you need to ask in the program forum for how to best use the programs to do what you want
http://forums.adobe.com/community/premiere_elements/content
http://forums.adobe.com/community/premiere/content -
How do you share one apple Id with two phones
I would like to know how to add a second iPhone to my apple account
What do you mean " add a second iPhone to my apple account"?
-
How do you replace a time capsule with a newer one
How do you replace a time capsule with a newer one?
LOL.. pull the old one out.. put the new one in. Setup the new one.. do not copy setting from the old one.. it is better to start over and never copy configuration files.. although you might get away with it.
Plug the old TC into the new one.. change it to bridge mode.
You can then access and copy old backups to the new TC if you want. Although IMHO just keep the old TC for 6months. .then wipe it and sell it or use in different role. Do start clean fresh backups on the new TC.
If that is all useless. ask the specific question and we can try for a specific answer. -
Replace one itunes account with another
I have the itunes application downloaded on my laptop but i recently made another itunes account and i want the new one to be on the Itunes application. So i uninstalled the application thinking that if i downloaded it again it would ask me for an account. Except all it did was restore the old account. I am wondering if anyone knows how to replace one itunes account with another. If you know anything that can be useful comment.
Store > Sign Out
Store > Sign In
All purchases remain tied to the account used to buy them, but you can authorize iTunes to multiple accounts and put protected content from up to five on your devices. Generally best to stick to one account if possible. More so once you get to iOS devices as managing app updates over multiple devices is a chore.
tt2 -
How Can I replace newScale Text Strings with Custom Values?
How Can I replace newScale Text Strings with Custom Values?
How can I replace newScale text strings with custom values?
All newScale text is customizable. Follow the procedure below to change the value of any text string that appears in RequestCenter online pages.
Procedure
1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
a) Navigate to the RequestCenter.ear/config directory.
b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
c) Save the file.
d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
e) Stop and restart the RequestCenter service.
f) Log in to RequestCenter and browse to the page that has the text you want to overwrite. In front of the text you will now see the String ID.
g) Note down the String ID's you want to change.
2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
3. Create the following sub-directory: res/resources
4. Create the following empty text files in the directory you just created:
RequestCenter_0.properties
RequestCenter_1.properties
RequestCenter_2.properties
RequestCenter_3.properties
RequestCenter_4.properties
RequestCenter_5.properties
RequestCenter_6.properties
RequestCenter_7.properties
5. Add the custom text strings to the appropriate RequestCenter_<Number>.properties file in the following manner (name-value pair) StringID=YourCustomTextString
Example: The StringID for "Available Work" in ServiceManager is 699.
If you wanted to change "Available Work" to "General Inbox", you would add the following line to the RequestCenter_0.properties file
699=General Inbox
Strings are divided into the following files, based on their numeric ID:
Strings are divided into the following files, based on their numeric ID:
String ID File Name
0 to 999 -> RequestCenter_0.properties
1000 to 1999 -> RequestCenter_1.properties
2000 to 2999 -> RequestCenter_2.properties
3000 to 3999 -> RequestCenter_3.properties
4000 to 4999 -> RequestCenter_4.properties
5000 to 5999 -> RequestCenter_5.properties
6000 to 6999 -> RequestCenter_6.properties
7000 to 7999 -> RequestCenter_7.properties
6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
7. Restart RequestCenter.
Your customized text should be displayed.I've recently come across this information and it was very helpful in changing some of the inline text.
However, one place that seemed out of reach with this method was the three main buttons on an "Order" page. Specifically the "Add & Review Order" button was confusing some of our users.
Through the use of JavaScript we were able to modify the label of this button. We placed JS in the footer.html file that changes the value of the butt -
How do I replace one adaptor from my Apple World Traveler Adaptor Kit?
How do I replace one adaptor from my Apple World Traveler Adaptor Kit?
If you have lost it then you might find a single replacement you can purchase at a AAA travel store. You could call your local Apple Store to ask, but Apple does not sell the adapters separately.
-
I have one itunes account with two phones assigned to it, sons and daughters, (5s). When i phone one of the numbers both phones have started to ring, only when connected to wifi at home. The problem does not occur when not connected to wifi. How do i resolve this please? texting is fine it is only when ringing one of the numbers.
<http://support.apple.com/kb/HT6337>
"To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls."
Maybe you are looking for
-
How can I see the last location of a now dead ipod touch 4G that had find my iphone turned on?
How can I see the last location of a now dead ipod touch 4G that had find my iphone turned on? I can see my macbook but I cant see the last location of my ipod touch. I lost it a few weeks ago and figured it would show up. But it has not and I need i
-
Applications directory is empty
I just upgraded to Yosemite on my MacBookPro Late2012 - and now I find that no applications are shown within the Applications directory when I click on it. Installed applications work - so they must be there - but even in my timemachine backup the Ap
-
help
-
Checking for updates.... forever...
Every time I connect to my PC I'm getting the above, but it NEVER provides an update, just keeps "checking". My phone also tells me there's an update available. Anyone know how to resolve this? THANKS
-
How to find the available parameters in Framework Page
Hi All, I am new to OA Framework need some help. I need to find out the list of parameters for a Framework page. Once I know the available parameter then I can pass the value so that page rendering will be based on the parameter value. How to know th