string

How to make an NSString path (file name) safe

Hi, I'm using very tricky fighting methods :) to make a string like 'Fi?le*/ Name' safe for using as a file name like 'File_Name'. I'm sure there is a cocoa way to convert it. And I'm sure the best place to ask is here :) Thank you! ...

Should one use strict comparison in Strings?

I know that for instance, using: if (in_array('...'), array('.', '..', '...') === true) Over: if (in_array('...'), array('.', '..', '...') == true) Can increase performance and avoid some common mistakes (such as 1 == true), however I'm wondering if there is a reason to use strict comparisons on strings, such as: if ('...' === '.....

The fastest way to compare a partial string?

Hello, I have to compare a partial string "SKILL_______EU_______WAND_______CLERIC_______BASE_____01" with "SKILL".It's meant to check if the first four characters are "SKILL".or the first character only,optimization is needed here! My problems: I don't know how to do an optimized comparison. It has to be repeated 35 000 times so it ...

JavaFX: formatting Duration into String?

Is there some kind of built-in method or a simple function that will convert Duration into a string in the hh:mm:ss format? For example, I am looking for something that would convert a Duration of 123402 ms into a String of "2:03". ...

C++ string addition

Simple question: If I have a string and I want to add to it head and tail strings (one in the beginning and the other at the end), what would be the best way to do it? Something like this: std::string tmpstr("some string here"); std::string head("head"); std::string tail("tail"); tmpstr = head + tmpstr + tail; Is there any better way ...

Display String Tokens

I have String tokens separated by $$ which are list of particulars which are further separated by comma (e.g. Peter Adams,255 Jhonson Street, NY,74322 $$ Mary Luther,54 Eglinton Ave.,Mississauga,ON L5A1W6) I want to display above in following way Name : Peter Adams Addr :255 Jhonson Street City : NY Pincode :74322 Name : Mary Luther A...

DataTable Select: Expression with a space problem...

Situation: Hello! I have a little problem in a C# project. I am using the Select method from a DataTable object and using an expression to get what I want but I am having some trouble with a space in one of the strings I am using for the expression. So here is a code sample of what I have: DataTable table; //... DataRow[] rows = tab...

Efficient Algorithm for String Concatenation with Overlap

We need to combine 3 columns in a database by concatenation. However, the 3 columns may contain overlapping parts and the parts should not be duplicated. For example, "a" + "b" + "c" => "abc" "abcde" + "defgh" + "ghlmn" => "abcdefghlmn" "abcdede" + "dedefgh" + "" => "abcdedefgh" "abcde" + "d" + "ghlmn" => "abcdedghlmn" "abcdef...

Ruby implementation is_numeric? for Strings, need better alternatives

I wanted to validate 'numericality' of a string (its not an attribute in an active-record model). I just need it to be a valid base 10, positive integer string. I am doing this: class String def numeric? # Check if every character is a digit !!self.match(/\A[0-9]+\Z/) end end class String def numeric? # Check...

Difference between string and char[] types in C++

Hello, I know a little C and now I'm taking a look at C++. I'm used to char arrays for dealing with C strings, but while I look at C++ code I see there are examples using both string type and char arrays: #include <iostream> #include <string> using namespace std; int main () { string mystr; cout << "What's your name? "; getline ...

jquery append to string variable

Hello guys. How can I append a word to an already populated string variable with spaces? ...

Strings in C: pitfalls and techniques

Dear all; I will be coaching an ACM Team next month (go figure), and the time has come to talk about strings in C. Besides a discussion on the standard lib, strcpy, strcmp, etc., I would like to give them some hints (something like str[0] is equivalent to *str, and things like that). Do you know of any lists (like cheat sheets) or your...

String Help - Objective C

Hi all, I'm trying to make an app that will respond to your command when inserted. So you type in any text in the first box and press enter. It will respond with a response in the 2nd field. I'm not sure how the coding is done here. I'm having trouble with the "if inputbox text = @"whatever", I'm pretty sure that is completely off. Here...

Write unicode string into file with CodeGear C++ Builder 2009

Hi everyone. I have just switched from Builder 6 to Builder 2009 and have a question. How can I write unicode string to a file? TBytes Preamble1 = TEncoding::Unicode->GetPreamble(); UnicodeString str1("string1"); int len = TEncoding::Unicode->GetByteCount(str1); FileWrite( iFile,&Preamble1[0],Preamble1.Length ); FileWrite( iFile,str...

Help with regex validation on string of text in c#

Hi, im trying to validate a string of text that must be in the following format, The number "1" followed by a semicolon followed by between 1 and three numbers only - it would look something like this. 1:1 (correct) 1:34 (correct) 1:847 (correct) 1:2322 (incorrect) There can be no letters or anything else except numbers. Does anyo...

PHP long string without newline

Hi, I have a long string in php which does not contain new lines ('\n'). My coding convention does not allow lines longer than 100 characters. Is there a way to split my long string into multiple lines without using the . operator which is less efficient - I don't need to concat 2 strings as they can be given as a single string. Than...

"Invalid" iphone string

I'm converting data (from a web page) to a string). The basic code works (but there's been some subtle change somewhere - maybe on server). NSLog shows the expected string (maybe 1000 chars long). However, when I float over responseString, it shows "Invalid". Worse, parsing with componentsSeparatedByCharactersInSet does not work. I...

Removing strings from C source code

Can anyone point me to a program that strips off strings from C source code? Example #include <stdio.h> static const char *place = "world"; char * multiline_str = "one \ two \ three\n"; int main(int argc, char *argv[]) { printf("Hello %s\n", place); printf("The previous line says \"Hello %s\"\n", place); return 0...

Flex DataGridColumn display multiline string data

Is it possible to display a multiline string in a Flex DataGridColumn? i.e. Display: Text line one. Text line two. I've tried putting "\n","\r","&#13;" when storing the string but nothing seems to work. Currently only "Text line one." is displayed and the rest is hidden in the cell. I would prefer not to use "wordWrap=true" ...

Java Strings storing byte arrays

I want to store a byte array wrapped in a String object. Here's the scenario The user enters a password. The bytes of that password are obtained using the getBytes() String method. They bytes are encrypted using java's crypo package. Those bytes are then converted into a String using the constructor new String(bytes[]) That String is ...