473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I search for quotation marks within a string?

If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?

Jul 7 '06 #1
5 17618
try "\""

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

<to******@gmail.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?

Jul 7 '06 #2
Besides Greg's solution, when you you search for a single character, you can
also use single quote; between single quotes, you can use the double quote
character.

So x = myString.IndexOf('"') will work too (that is ', followed by " then ')

/LM

<to******@gmail.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?

Jul 8 '06 #3
If you are using VB (which is my guess, as you have no semicolon at the
end of the statement):

x = myString.IndexOf("""")

If you are using C#:

x = myString.IndexOf("\"")
or
x = myString.IndexOf(@"""")
or
x = myString.IndexOf('"')

to******@gmail.com wrote:
If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?
Jul 8 '06 #4
guy
use ControlChars.Quote, it is more readable (or at least i think so;-)

hth guy

"to******@gmail.com" wrote:
If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?

Jul 9 '06 #5
I don't consider a quotation mark as a control character, but, yes, that
is a good alternative. :)

A curious thing about the ControlChars class, though, is that it has a
public constructor. Does anybody know why? An instance of the class is
totally useless, as all members that are not inherited from Object are
constants.

guy wrote:
use ControlChars.Quote, it is more readable (or at least i think so;-)

hth guy

"to******@gmail.com" wrote:
>If I want to search for a character within a sring, I normally use

x = myString.IndexOf("T")

However, what if I want to look for a quotation mark within the string?

I have tried

x = myString.IndexOf(""")
x = myString.IndexOf(")
x = myString.IndexOf(" " ")

and so on. Nothing works. How do I do this?

Jul 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NikkoW | last post by:
I need to assign a string to a variable but the text string includes quotation marks: Example: MyString = "He turned and said "Hello" before leaving." When the compiler hits the quotation...
63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English double-quote character, ", regardless of the lang...
4
by: Thomas Miskiewicz | last post by:
Hi! Is using of a double quotation mark with a URL a problem? For example: http://myserver.com/query?field1=something&field2=test&params="field1=test1"+"field2=test2" Regards Thomas
7
by: Paradigm | last post by:
I am trying to create a recordset where some text fields are matching. The problem is that some of the text fields contain quotation marks. I have tried to create the sql string using replace eg....
1
by: vince | last post by:
need to create a string with embedded quotation marks, like string str1 = " they said "go away" "; How can this be done? Thanks, vince
2
by: bcastaing | last post by:
My Windows service includes the following lines: string Arguments3 = @"%OvAgentDir%\bin\OpC\cmds\ref-ovo-services.vbs ServiceApplicatif ServiceOVO"; string expandedArguments3 =...
3
by: Ufit | last post by:
Simple,dumm question - how to include quotation marks in the string? F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client data.mdf";Integrated Security=True;User Instance=True" I get syntax...
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in my browser. I'm considering going through and...
12
by: Adam Right | last post by:
Hi ! In my sql statement, i have to use field names and table name with quotation marks. like that : ----------------------------------------------------------------------- string sqlStr = ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.