string

split a string using a open and close tag.

Hi there: I wish to known if exist a clean way to split a string using different tags for opening and ending. For example: <&field1&>outside<&field2&> using the function split: string[] dd={"<&","&>"}; string[] b1 = a1.Split(dd,StringSplitOptions.None); it show me: 0: 1:field1 2:outside 3:field2 4: (that ...

How can I get a human-readable description from a signal number?

Does the POSIX standard or another C standard provide a way to recover a meaningful message from a signal number, in the same way that strerror() makes it possible to recover a message from errno? The Gnu C library has strsignal(), but if possible, I would like something portable to BSD and other Unix variants. ...

NSString setter using isEqualToString

In the Pragmatic Core Data book, I came across this code snippet for an NSString setter: - (void)setMyString:(NSString*)string; { @synchronized(self) { if ([string isEqualToString:myString]) return; [myString release]; myString = [string retain]; } } Is there any reason to use [string isEqualToString:myString] instead of...

Classify array of strings based on commonalities

I have huge list (200000) of strings (multi word). I want to group these strings based on comman array of word match among these strings. I cant think of a low computation time algorithm for this "AB 500" "Bus AB 500" "News CA" "News CA BLAH" My plan was a. Tokenize them to words. b. Create a global array tokens c. Compare those...

How to determine whether an object can be convert to meaningful string in C#

Hi all, I need to determine whether the ToString() method of an object will return a meaningful string instead of its class name. For example, bool, int, float, Enum, etc. returns meaningful string, instead an instance of ArrayList will return "System.Collections.ArrayList". If there a simple way to archive that? Thanks in advance. Reg...

Check if string is of SortableDateTimePattern format

Hi, Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression? I've got a form where users can input a copyright date (as a string), and these are the allowed formats: Year: YYYY (eg 1997) Year and month: YYYY-MM (eg 1997-07) Complete date: YYYY-MM-DD (e...

String to Unicode conversion with VB.NET

How could i convert a Greek string, to Unicode with VB.NET, without knowing the source encoding? ...

C#: Extract only right most n letters from a string

How can I extract a substring which is composed of the rightmost six letters from another string? Ex: my string is "PER 343573". Now I want to extract only "343573". How can I do this? ...

How to split a string into a List<string> from a multi-line TextBox that adds '\n\r' as line endings?

I've got a textbox in my XAML file: <TextBox VerticalScrollBarVisibility="Visible" AcceptsReturn="True" Width="400" Height="100" Margin="0 0 0 10" Text="{Binding ItemTypeDefinitionScript}" HorizontalAlignment="Left"/> with which I get a st...

C++ std::string and NULL const char*

I am working in C++ with two large pieces of code, one done in "C style" and one in "C++ style". The C-type code has functions that return const char* and the C++ code has in numerous places things like const char* somecstylefunction(); ... std::string imacppstring = somecstylefunction(); where it is constructing the string from a c...

Where is the prototype property on strings in JavaScript?

I just noticed that there is no prototype property on strings in JavaScript. This is a pedagogical question while I try to wrap my head around the JavaScript type system but what gives? How come "abc".toString() works? And how would I go about extending strings? If I wanted to be able to do "hey you!".alertDialog() for example? ...

Getting a text file into a two dimensional ragged array in Java.

Hey guys this is a followup to my previous question. I now have a text file which is formatted like this: 100 200 123 124 123 145 What I want to do is get these values into a two dimensional ragged array in Java. What I have so far is this: public String[][] readFile(String fileName) throws FileNotFoundException, IOException { ...

find Char width in pixels for various Arial fontsizes

Hi, I have a program that is manually generating a pdf using PDFSharp in C#. Although it is rather tedious I have to use it and am nearing completion of the task. Only one issue remains Problem: I am wondering how I can find out what the width of a given char is for a given font size in Arial I am having trouble coming up with a more ...

Strip first and last character from C string

I have a C string that looks like "Nmy stringP", where N and P can be any character. How can I edit it into "my string" in C? ...

Removing Spaces from a String in C?

What is the easiest and most efficient way to remove spaces from a string in C? Thanks. ...

Why can't compiler derive string length for array of strings?

Note: This question was influenced by this answer. The following is valid C code: char myString[] = "This is my string"; This will allocate a string of length 18 (including the \0 character) on the stack and assign the specified value to it. However, the following: char myStrings[][] = {"My 1st string", "My 2nd string", "My 3rd str...

as3 - format a timestamp string from mysql

I'm receiving a date field from a php file, and I need to format it. I get this string: "2009-11-12 17:58:13" I want to convert to "November 12, 2009 5:58:13 pm" I tried to work with the Date class, but I get stuff like this: Type Coercion failed: cannot convert "2009-11-12 17:58:13" to Date. Anyone know of any good utilities for doin...

Using Recursion To Compare Strings To Determine Which Comes First Alphabetically Java

I am trying to write a method that uses recursion to compare the strings str1 and str2 and determine which of them comes first alphabetically (i.e., according to the ordering used for words in a dictionary). If str1 comes first alphabetically, the method should return the integer 1. If str2 comes first alphabetically, the method shoul...

Is it bad practice to use string literals in xpath expressions?

I currently use string literals in my xpath expressions. For example: paragraphList = root.SelectNodes("paragraph"); I know you should generally avoid using literal values, but I figure this is safe, since the names of your xml nodes will rarely change. Is this bad practice, or am I same? ...

Print Alternating Characters From Two Strings (Interleaving) Using Recursion Java

I'm trying to write a method that uses recursion to print the string formed by "interleaving" the strings str1 and str2. In other words, it should alternate characters from the two strings: the first character from str1, followed by the first character from str2, followed by the second character from str1, followed by the second charact...