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? ...
Hi, Does "hello".ToString() produce a new string or is it smart enough to return a reference to the same object? ...
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 (...
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? ...
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...
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...
What is the easiest way to clear an array of strings? ...
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 can I iterate through a string in Java? I'm trying to use a foreach style for loop for(char x : examplestring) { //action } ...
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 ...
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"; ...
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...
I have a string in PHP that is a URI with all arguments: $string = http://domain.com/php/doc.php?arg1=0&arg2=1&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&arg2=1 I will always want to remove...
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 ...
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...
Is there any simple method to concatenate '0' before an int variable. Like: int i = 2; // produce i = someMethod(i); // output: i = 02 ...
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...
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? ...
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 ...
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...
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 ...