string

C# sort list of strings with specific scandinavian culture in mind

Hi, i have a list of country names. Now i want to sort them alphabeticly, with the users culture in mind. I have the 4 scandinavian cultures norway, sweden, danmark en finland. For sweden, the Ö (O with two dots if it's not printed correctly) must appear at the end, after the Z, but for danmark it's just the letter O, so it must appear...

Loop Problem: Assign data to different strings when in a loop

I have a string which consists of different fields. So what I want to do is get the different text and assign each of them into a field. ex: Hello Allan IBM so what I want to do is: put these three words in different strings like string Greeting = "Hello" string Name = "Allan" string Company = "IBM" //all of it happening in a loop. ...

The SHORTEST way to remove multiple spaces in a string in Python

Suppose this is the string: The fox jumped over the log. It would result in: The fox jumped over the log. What is the simplest, 1-2 liner that can do this? Without splitting and going into lists... ...

Seach&Replace strings in PDF with perl/ruby/php

Hi! I'm looking for a way to script replacing strings in PDF documents. I can use either perl, ruby or php. If possible, regex would be a blast... Thank you! ...

C++ run time error with protected members

I am trying to do a homework assignment where we insert a string into a string at a specified point using a linked stack, hence the struct and typedef. Anyway, when I try to access stringLength in the StringModifier class inside the InsertAfter method, I get a run time error and I cannot figure out what the problem is. I should be able t...

C# Remove multiple char types from end of string

I have a loop that builds up address fields, some of these fields may be empty at the end of the string List<string> list = new List<string>(); //list can contain any number of values, some of which might be "" (empty string) string returnValue = ""; for (int iRow = 1; iRow <= list.Count; iRow++) string += String.Format("{0}, ", l...

Using gsub to replace a particular character with a newline (Ruby, Rails console)

Hey there Annoying problem. I am trying to replace all semicolon characters in my Model's description field with newline characters (\n). The database is sqlite. The field is of type text. If I do it manually at the rails console (manually typing the description for a single record using \n for line breaks), the rails console automati...

Objective-C can't use stringWithContentsOfURL data in IF statement

Hey, I'm trying to ping my server and check the version of the app - all goes well so far: NSURL *url = [NSURL URLWithString:@"http://thetalkingcloud.com/static/ping_desktop_app.php?v=1.1"]; NSError *theNetworkError; NSString *content = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&theNetworkError]; ...

Java: str.replaceAll() not working

I'm trying to cleanse one String from another. before = before.replaceAll(Constants.GENE_START_SEQUENCE, ""); And yet, the following assertion sometimes fails: assert before.indexOf(Constants.GENE_START_SEQUENCE) == -1 : before; This is what the assert spits out: IIAOOOCOAAAOCCIOOOACAIAOACICOOIAIOOICIIOIIOICOICCCOOAOICOCOOIIOOAOAA...

Getting all the values of a array of Strings in one String

if I have, String[] s = new String[3]; s[0] = "Ap"; s[1] = "p"; s[2] = "le"; String result = ? If I want to get Apple out of s without looping, how do I do that? Any short cut? ...

Just a question about str_replace

Hello, I have a question about str_replace in PHP. When I do: $latdir = $latrichting.$Lat; If (preg_match("/N /", $latdir)) { $Latcoorl = str_replace(" N ", "+",$latdir); } else { $Latcoorl = str_replace ("S ", "-",$latdir); } print_r($latdir); print_r($Latcoorl); print_r($latdir); gives :N52.2702777778 but print_r ($Latco...

How to enclose values in SQL commands?

An error-free column name syntax is [My Column] instead of My Column which causes an error. An error-free string value syntax is '25,00' instead of 25,00 which causes an error. I'm getting an error using single quotes to enclose values, if the column data type is numeric. Are there any other ways to enclose values safely for string or ...

How to use string and string pointers in C++

I am very confused about when to use string (char) and when to use string pointers (char pointers) in C++. Here are two questions I'm having. which one of the following two is correct? string subString; subString = anotherString.sub(9); string *subString; subString = &anotherString.sub(9); which one of the following two is correct?...

Java Strings: compareTo() vs. equals()

When testing for equality of strings in Java I have always used equals() because to me this seems to be the most natural method for it. After all, its name already says what it is intended to do. However, a colleague of mine recently told me had been taught to use compareTo() == 0 instead of equals(). This feels unnatural (as compareTo()...

Why is this string changed?

I have the following code, so far, I want to check if a file name is already in the linked list fileList (or flist). according to the output, the string saved in the first Node was changed somewhere in Node* getFileName(Node *&flist) How did this happen? Also, is there anything else that I'm doing is wrong or not safe regarding pointers ...

How to declare C array of strings

I'm working on a simple lex program for class, and in it I'm creating a very rudimentary symbol table, just an array of strings with a linear scan for search. I've declared it as: char* identifiers[100]; And I'm using it like so: found = false; for (i = 0; i < seen_identifiers; i++) { if (!strcmp(identifiers[i], yytext)) { ...

strncmp C Exercise

I'm trying to do exercise 5-4 in the K&R C book. I have written the methods for strncpy and strncat, but I'm having some trouble understanding exactly what to return for the strncmp part of the exercise. The definition of strncmp (from Appendix B in K&R book) is: compare at most n characters of string s to string t; return <0 if s...

permalink_fu for text fields: How can I convert from blob to string output?

If I use permalink_fu on a text field I get this for the resulting permalink: http://localhost:3000/243webb4ee4ff2227230b4232438591810c35d3f instead of http://localhost:3000/where-is-my-lost-cat I assume this is because the text field becomes a blob in the database and permalink_fu only knows how to operate on string fields. How ...

Immutability of Strings in Java

Consider the following example. String str = new String(); str = "Hello"; System.out.println(str); //Prints Hello str = "Help!"; System.out.println(str); //Prints Help! Now, in Java, String objects are immutable. Then how come the object 'str' can be assigned value "Help!". Isn't this contradicting the immutability of strings in ...

Hibernate case-insensitive utf-8/unicode collation that works on multiple DBMS

I'm looking for Hibernate annotation or .hbm.xml that allows me to specify a table column as case-insensitive string working in unicode/utf-8/locale-independent manner that works on multiple database engines. Is there any such thing? So that I can do query using Restrictions.eq("column_name", "search_string") efficiently. ...