string

Parsing a string in c#

Hi, Suppose there is an xml file like below: <Instances> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image1.jpg" ImageNumber = "1"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image2.jpg" ImageNumber = "2"/> <Bits = "16" XCoord = "64"...

How to detect the last character

I have a string and i want to know if the last character in my string is # example: String test="test my String #"; ...

How to read file.xml from resources to NSString with format?

Actually I have such a code: NSString *path = [[NSBundle mainBundle] pathForResource: @"connect" ofType: @"xml"]; NSError *error = nil; NSString *data = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding ...

Immutable Dot Net strings

I usually define my string variables in vb.net as Dim f_sName as string=String.Empty f_sName = "foo" Given the immutable nature of strings in .net, is there a better way to initialize strings and deal with the "Variable 'f_sName ' is used before it has been assigned a value. A null reference exception could result at runtime." warni...

Java how to replace 2 or more spaces with single space in string and delete leading spaces only

Looking for quick, simple way in Java to change this string " hello there " to something that looks like this "hello there" where I replace all those multiple spaces with a single space, except I also want the one or more spaces at the beginning of string to be gone. Something like this gets me partly there String mytext =...

How to assign HTML value to a asp.net string variable

I am using asp.net and C#. I want to send mail to my user in HTML format, I have the content in HTML format let say like this <table style="width:100%;"> <tr> <td style="width:20%; background-color:Blue;"></td> <td style="width:80%; background-color:Green;"></td> </tr> </table> Now I am unable to assign...

Opening a file in c++ by using a string array of adress

Hello guYz plz help me out in making it possible to open the files by the adress provided in an array of strings......... a way to open file is as given below... ifstream infile; infile.open("d:\aslam.txt"); but how can i open file providing an array of string as an adress of file..... like this infile.open(arr[i]); (but its not worki...

How to convert a file to string directly using C# ASP.NET

I asked a question regarding how to display aspx and cs code on page, One answer was to convert to string and display in textbox. Is there a function in C# ASP.NET which allows to convert file contents directly to a string? ...

Suggestion to reverse string in c#

Is this the right method to reverse a string? I'm planning to use it to reverse a string like: Products X1 X3 to X3 X1 Products I want it to be a global function which can be used elsewhere. public static string ReverseString(string input, string separator, string outSeparator) { string result = String.Empty; string[] temp =...

Parse Text using scanner useDelimiter

Looking to parse the following text file: Sample text file: <2008-10-07>text entered by user<Ted Parlor><2008-11-26>additional text entered by user<Ted Parlor> I would like to parse the above text so that I can have three variables: v1 = 2008-10-07 v2 = text entered by user v3 = Ted Parlor v1 = 2008-11-26 v2 = additional text entered...

realloc - converting int to char

I'm converting an array of integers into a char by iterating through the whole array, and then I'm adding the resulting string to ncurses's method new_item. For some reason I'm doing something wrong the way I reallocate memory, thus I get the the first column as: -4 Choice 1 0 Choice 1 4 Choice 2 1 Choic...

regular expression for string in c

Hi All, I am working writing a regular expression used to validate string in C. Here is to what I have gone so far '^"[A-Za-z0-9]*[\t\n]*"$' for rules - A string should begin with double quotes - May not contain a newline character However, I am not able to capture the rule for allowing '\' or '"' in a string if preceded with '\'. H...

In Android OS or Java, what's the difference between a character sequence and a string?

For the API (Android SDK API version 8) functions whose definitions list character sequence parameters, I can feed the function String instead. Best part is that they work the same way, no hassle, no warnings. Is there a difference between the two types? And more importantly, is there an inherent danger if I send the function a String i...

Encode/decode a long to a string using a fixed set of letters in Java

Given an arbitrary set of letters String range = "0123456789abcdefghijklmnopABCD#"; I am looking for 2 methods to encode/decode from long <-> String String s = encode( range, l ); and long l = decode( range, s ); So decode(range, encode(range, 123456789L)) == 123456789L And if range is "0123456789" thats the usual way of encodi...

sql server convert string to datetime

Hello, I have this string: '30/05/2010', and I would like to enter it to a smallDatetime field. In the database it should look something like this 2010-05-30 15:33:25 Any Idea how? TY ...

Set fields with instrospection - Problem with String.valueOf(String)

Hey there! I'm setting public fields of the Object 'this' via reflection. Both the field name and the value are given as String. I use several various field types: Boolean, Integer, Float, Double, an own enum, and a String. It works with all of them except with a String. The exception that gets thrown is that no method with the Signatur...

Replacing text with a link in jQuery

I'm trying to replace a small part of text in a large HTML document with my own element which I create on the fly. The text may be a huge bulk of text, html, images, what-ever, and what I want is to find the first (or all) the position of a certain string, and replace it with an element that I create using $('< span>'). Using simple te...

Java: getting incorrect string.length() after using trim()

I have the string "22" and I'm getting 3 as length; I used .trim() What else could be a reason for this? ...

Searching for one string in another string

Hey Let's say I have String Table that have a few strings (like mother, father, son) and now in this String Table I want to find every word that contains string "th" for example. How should I do it? Method string.equals(string) won't help here. ...

C++: Chr() and unichr() equivalent?

I could have sworn I used a chr() function 40 minutes ago but can't find the file. I know it can go up to 256 so I use this: std::string chars = ""; chars += (char) 42; //etc So that's alright, but I really want to access unicode characters. Can I do (w_char) 512? Or maybe something just like the unichr() function in python, I just ca...