string

Does ToString() produce a new string on when used on strings?

Hi, Does "hello".ToString() produce a new string or is it smart enough to return a reference to the same object? ...

Tokenize an environment variable and save the resulting token in a char**

Hi. I'm attempting to create an array of strings that represent the directories stored in the PATH variable. I'm writing this code in C, but I'm having trouble getting the memory allocation parts working. char* shell_path = getenv ("PATH"); char* tok = strtok (shell_path, SHELL_PATH_SEPARATOR); int number_of_tokens = 0, i = 0; while (...

strip span tags from string with jquery

I am wanting to take the text value of a p tag when I press enter $.keynav.enterDown = function () { var accom = $('#suggestions p.keynavon').html(); alert(accom); } This is working great but the results contain <span> and </span> tags, is there anyway I can strip those tags from the string? ...

How to do a Python split() on languages (like Chinese) that don't use whtespace as word separator?

I want to split a sentence into a list of words. For English and European languages this is easy, just use split() >>> "This is a sentence.".split() ['This', 'is', 'a', 'sentence.'] But I also need to deal with sentences in languages such as Chinese that don't use whitespace as word separator. >>> u"这是一个句子".split() [u'\u8fd9\u662f\u...

PHP: Make first letter capital in list?

As i have this: $full_name = $data['full_name']; list($firstname, $lastname) = explode(' ', $_POST['full_name']); (after this comes a query where it inserts $lastname and $firstname) Where should i use ucfirst() ? Should i just make new variables again? $newfirstname = ucfirst($firstname); $newlastname = ucfirst($lastname); or ca...

Clear array of strings

What is the easiest way to clear an array of strings? ...

java 6 replaceall replacefirst

Hi all, The following regex works when used in string.replaceall() but not in case of string.replaceFirst(). String: TEST|X||Y|Z|| Expected output: TEST|X|**STR**|Y|Z|| Regex: string.replaceAll( "(TEST\\|[\\|\\|]*\\\\|)\\|\\|", "$1|ST|" ); Output (not desired): TEST|X|**STR**|Y|Z|**STR**| string.replaceFirst( "(TEST\\|[...

How to iterate through a String

How can I iterate through a string in Java? I'm trying to use a foreach style for loop for(char x : examplestring) { //action } ...

Python - Best way to compare two strings, record stats comparing serial position of particular item?

Hi all, I'm dealing with two files, both of which have lines that look like the following: This is || an example || line . In one of the files, the above line would appear, whereas the corresponding line in the other file would be identical BUT might have the '||' items in a different position: This || is an || example || line . I ...

Question about == operator in java

public class Demo { public static void main(String[] args) { String s1 = "Hello"; String s2 = "Hello"; System.out.println("s1 == s2 " + (s1 == s2)); String s5 = "Hel" + "lo"; String s6 = "He" + "llo"; System.out.println("s5 == s6 " + (s5 == s6)); String s7 = "He"; ...

Select parts of a string till a certain character and store in an array

Hi Guys, I am trying to select parts of a string till a certain character, -----, and put them in an array. For eg. in the below paragraph I want to store from "Game..the", "next....player", "free....zone" and "or....career" in one array in php. Gamers can also take on Blitz a wild, high-pressure challenge where players must race agai...

remove a part of a URL argument string in php

I have a string in PHP that is a URI with all arguments: $string = http://domain.com/php/doc.php?arg1=0&amp;arg2=1&amp;arg3=0 I want to completely remove an argument and return the remain string. For example I want to remove arg3 and end up with: $string = http://domain.com/php/doc.php?arg1=0&amp;arg2=1 I will always want to remove...

c string basics, why unassigned?

Hi, I am trying to learn the basics, I would think that declaring a char[] and assigning a string to it would work. thanks int size = 100; char str[size]; str = "\x80\xbb\x00\xcd"; gives error "incompatible types in assignment". what's wrong? thanks ...

What does the @ do in a SQL statement?

For example, when creating a command text for a SqlServer ce statement, the example has you use command.CommandText = "INSERT INTO Region (RegionID, RegionDescription) VALUES (@id, @desc)"; I understand how to run sql queries, but have always just passed the database system a string with sql statements. This is new to me, and I woul...

Prefix '0' to the int variable which less than '10', How?

Is there any simple method to concatenate '0' before an int variable. Like: int i = 2; // produce i = someMethod(i); // output: i = 02 ...

Ellipsis with C# (ending on a full word)

Hi all, I'm trying to implement ellipsis in Umbraco, the requirement being 15 characters of intro text but always ending on a full word. I thought of using XSLT, but then realised that I can use a simple extension method written in C# instead. I can easily substring the text and append "..." but am stuck with the issue of having to en...

String Comparison?

Possible Duplicate: Differences in string compare methods in C# Is there any difference between these methods? string.Compare(s1, s2) == 0 s1.CompareTo(s2) == 0 s1.Equals(s2) s1 == s2 Which one should I use? ...

Python: any way to perform this "hybrid" split() on multi-lingual (e.g. Chinese & English) strings?

I have strings that are multi-lingual consist of both languages that use whitespace as word separator (English, French, etc) and languages that don't (Chinese, Japanese, Korean). Given such a string, I want to separate the English/French/etc part into words using whitespace as separator, and to separate the Chinese/Japanese/Korean part ...

How to convert a char array into string based hex-stream (ostringstream)

Hi, in C++ (on Linux with gcc) I'd like to put a byte array (vector<unsigned char>) to a ostringstream or a string. I know that I can use sprintf but it doesn't seem to be the best way to use char* also. btw: this link did not help Edit: All answer work so far. But I did not meantion, that I'd like to convert the bytes/hex-values int...

Is there a way to compress small string ( 100 char ) to about ( 20 char ) BY C# ?

I search for a way to compress small string ( 100 char ) to a string in about (15-25) char that allow me to decompress it again ? UPDATE: string is just a text and i'll not store it I just want to pass a string of about 100 char from asp.net web page to another web page in a query string so i want to compress it first before pass it in ...