Hi,
This has been driving me completely crazy, and I'm haunted by it day and night, and I'm sure that there's a simple answer that'll make me bash my head on a wall, but I have not found that answer anyway.
So, I ask now, is there some escape sequence, or some method of finding the # character in a string?
I've also had minor issues with other characters in other situations, like a tab next to a couple of spaces, stuff like that, but all I want to know now is what represents the "#" character in strings.
Thanks,
Ashton
P.S. Again, sorry if it's so easy that it's stupid. I'm not a n00b programmer, proof is my <link removed> project, but seriously, this is driving me crazy. EDIT by Mod:
We don't need proof, we help n00bs as well as advanced programmers 9 71056 Plater 7,872
Recognized Expert Expert
The # character represents the # character...jus t like a J represents a J....?
I'm not sure what you are having trouble with?
string.IndexOf( "#") should tell you where in the string the first "#" resides? -
string test="dan likes the #14 best";
-
int n = test.IndexOf("#");
-
if (n != -1)
-
{
-
MessageBox.Show("Found at: " + n.ToString());
-
}
-
Please post the string you are trying to parse for the # character. Also any code that you have tried so far.
thanks
Nathan
If understanded u well u can do like this:
string example = "1234#56890 ";
bool yesno = false;
for(int i=0; i<example.Lengt h; i++)
{
if(substring(i, 1) == "#") yesno = true;
}
So if # exist in string yesno will be true or u can pick up i as pointer where
in string it is ....
Also if u wana cast out spaces from string u can use
for(int i=0; i<example.Trim( ).Length; i++) instead
Hope will help if understanded you wath you need
- string s = "abcde#fg";
-
int index = s.IndexOf("#");
You're doing it the hard way. IndexOf returns the first instance of the search pattern. If it doesn't find it, it returns -1.
To trim: -
string s = " something here ";
-
s = s.Trim();
-
//now s = "something here"
-
You can also use .TrimEnd() and .TrimStart()
Plater 7,872
Recognized Expert Expert
Also, strings work as literal character arrays. No need for the substring()
So: -
string fred="jon's new car";
-
if(fred[4]=='s')
-
{//whatever you want
-
}
-
Thanks for the replies.
Well, I've got this syntax richtextbox, one that does colour-coding to make it easier to read code, shader code specifically, HLSL, and there are two keywords, "#include" and "#define" that I want to highlight.
Trouble is, when I add either of those as a keyword: - syntaxRichTextBox1.Settings.Keywords.Add("#include");
-
syntaxRichTextBox1.Settings.Keywords.Add("#define");
It doesn't highlight those keywords at all. I've noticed that I get similar inabilities to find # characters in not-so-fancy applications I've developed.
The SyntaxRichTextB ox I found here: http://www.codeproject.com/KB/edit/S...chTextBox.aspx
I can settle for just highlighting "include" and "define" by themselves, it's only a bit annoying that # doesn't work.
Thanks,
Ashton
Plater 7,872
Recognized Expert Expert
That sounds like an implementation failure on the part of whoever made the custom RichTextBox you are using, and not a fault of string character indexing.
That sounds like an implementation failure on the part of whoever made the custom RichTextBox you are using, and not a fault of string character indexing.
Yeah, I've been looking through the code more.
There some fancy .NET functions to seek certain character sequences being used. I've tried changing a few settings, but #s are still not found. I forgot the name of the function, so I'll reply back when I find it again.
Something to do with System.Text.Reg ularExpressions I think.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: MLH |
last post by:
Is an apostrophe a character of special significance to MySQL in a way
that would cause "Bob's dog" to become translated into a 12-character
string when typed into a MySQL memo field? If I type Bob's dog into an
Access memo field, I get a string that is 9-characters long.
When I read "Bob's dog" from a memo field in a MySQL table attacted
to MS Access via MyODBC driver, it displays as "Bob's dog" - a
twelve character string. the '...
|
by: beta |
last post by:
Hello everyone,
I need some help here. If anyone has encountered this, knidly give me
your advice.
I have a command button (Command0) and a listbox (List1). Upon
clicking the command button, I want my listbox to be populated. Please
look at the code below. The fields Day2 and Filename are both text
fields. My problem is that Day2 field has rows with the text value
"N/A" (without the quotes). MS Access is evaluating the "/" sign in
|
by: Dan |
last post by:
I wish to replace all the occurrances of " with " within a string.
I have tried using myString.Replace("\"", """), but this does not work
Any suggestions will be greatly appreciated
Thanks
|
by: Chris Thunell |
last post by:
I'm looking to find in a long string an instance of 4 numbers in a row, and
pull out those numbers.
For instance:
string = "0104 PBR", i'd like to get the 0104.
string="PBR XT 0105 TD", i'd like to get the 0105.
The numbers will always be 4 digits together.
(I'm using vb.net)
Any help would be greatly appreciated!
Chris
cthunell@pierceassociates.com
|
by: lovecreatesbeauty |
last post by:
Hello experts,
I write a function named palindrome to determine if a character string
is palindromic, and test it with some example strings. Is it suitable
to add it to a company/project library as a small tool function
according to its quality? I will be very happy to get your suggestion
from every aspect on it: interface design, C language knowledge or
algorithm efficient.
Sincerely,
| |
by: eric.goforth |
last post by:
In an xsl stylesheet, I have
<xsl:when test="string-length(//mystuff) > 0">
<xsl:attribute name="someattribute">blahblahblah</xsl:attribute>
</xsl:when>
In the xml that mystuff is several layers deep, does the // do a search
in the xpath?
<test>
|
by: sunmat |
last post by:
To find number of character without space using java
Example:
String = prabu sun
No. of char =8
plz send me code
|
by: manchin2 |
last post by:
Hi,
Can anybody please provide the information about """ and its use, if possible please provide an example.
1)<tm:bom-expression>{Conf.getEquityConfLookupFields().getEventFieldText("AdditionalDisruption","Change in Law")}</tm:bom-expression>
2)07:41:08 Default ( call ( . ( call ( . Conf getEquityConfLookupFields ) ) getEventFieldText ) ( , AdditionalDisruption Change inLaw ) ) value=Not applicable
Can you please...
|
by: blazeboy |
last post by:
Hello,
I am using a SQL data source to insert records into a table. The table uses a GUID as the primary key (GoalEventID), and a GUID for a second field (GoalID) as a foreign key.
When I call SqlDataSource1.Insert() I get the exception : "Conversion failed when converting from a character string to uniqueidentifier."
I'd sure appreciate any help in resolving the issue. The code is below. Thank you.
---------------
|
by: fran7 |
last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in "" instead of "" otherwise I get an error message.
Can anyone suggest how to write it so that it writes " instead of "".
I have tried all combinations of adding " to the code but as soon as I think I am there I get throw out again.
if...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |