string

How to replace elements of unknown content and length in strings in Java?

I need help with replacing segments of a string in Java. I have tried both the String method 'replace' and StringTokenizer. As the segments of my strings is of unknown length I guess StringTokenizer is out of question. I also need to go through several strings (with many similar segments to replace in each string). I have assumed there ...

Optimal method to create a large string containing several variables?

I want to create a string that contains many variables: std::string name1 = "Frank"; std::string name2 = "Joe"; std::string name3 = "Nancy"; std::string name4 = "Sherlock"; std::string sentence; sentence = name1 + " and " + name2 + " sat down with " + name3; sentence += " to play cards, while " + name4 + " played the violin."; Thi...

EXC_BAD_ACCESS after modifying string

I am manipulating a large string by removing chunks of characters, and assigning the new string back to the original string. articleString = [articleString stringByReplacingCharactersInRange:startRange withString:@""]; articleString is an instance variable of type NSMutableString This seems to work fine the first time I go through t...

parse a character out of a string in javascript

if i have a number of string like this var info = "Information4Table" var next = "Joe5Table" var four = "ERweer11Table" var nice = "ertertertn14Table" and i want to parse out the number between the first word and the string "Table". So for the first item, i want to get "4" and in the last i would want to get "14". what would be the ...

convert non serializable object to string in C#

I have an object (User) which is not marked as [Serializable()]. I need to convert the entire object (including child objects) to string. This is an actual need to convert the object from a third party tool response which is not marked as [Serializable()]. How can i convert an entire C# object to string/xml of the above scenario? ...

How to compare almost similar Strings in Java (ME)? (String distance measure)

I would like to compare two strings and get some score how much these look alike. For example "The sentence is almost similar" and "The sentence is similar". I'm not familiar with existing methods in Java ME, but for php I know the levenshtein function. Are there better methods in Java? ...

please help me to create Nullable String Parameter in Vb.NET

please tell me how to implement Nullable Parameter of type string in vb.net Function: sub savedetail(byval name as string, byval age as integer) if name isnot nothing then some work end if end sub i am calling it like thing savedetail(nothing,34) //here is giving me format exception exception : System.FormatException: Input st...

C# String.Replace with a start/index (Added my (slow) implementation)

I'd like an efficient method that would work something like this EDIT: Sorry I didn't put what I'd tried before. I updated the example now. // Method signature, Only replaces first instance or how many are specified in max public int MyReplace(ref string source,string org, string replace, int start, int max) { int ret = 0; in...

String comparison (possibly a hidden character issue?)

I'm trying to do something fancy with a blogger blog, and when I'm looking at a particular blog, I'd like to be able to know which one it is. So, although there might be a better way of doing it, I've got this bit of code set up: //Get title of current blog currentTitle = document.getElementById("post-title").innerText; currentTitle = ...

Delete a matching substring ignore whitespaces

Hi , I need to delete a matching substring when found in string 1 ignoring whitespaces and charcters like -. The example I have is: string 1="The LawyerWhat happened to A&O's first female partner?The LawyerWhen Clare Maurice was made up at Allen & Overy (A&O) in 1985 she was the sole female partner at the firm. Twenty-five years later...

Trim characters in Java

How can I trim characters in Java? e.g. String j = “\joe\jill\”.Trim(new char[] {“\”}); j should be "joe\jill" String j = “jack\joe\jill\”.Trim("jack"); j should be "\joe\jill\" etc ...

Using operator+ without leaking memory?

So the code in question is this: const String String::operator+ (const String& rhs) { String tmp; tmp.Set(this->mString); tmp.Append(rhs.mString); return tmp; } This of course places the String on the stack and it gets removed and returns garbage. And placing it on the heap would leak memory. So how shoul...

How to swap adjacent bytes in a string of hex bytes (with or without regular expressions)

Given the string (or any length string with an even-number of word pairs): "12345678" How would I swap adjacent "words"? The result I want is "34127856" As well as, when that's done I need to swap the longs. The result I want is: "78563412" ...

How can I add a huge string to a textbox efficiently?

I have a massive string (we are talking 1696108 characters in length) which I have read very quickly from a text file. When I add it to my textbox (C#), it takes ages to do. A program like Notepad++ (unmanaged code, I know) can do it almost instantly although Notepad takes a long time also. How can I efficiently add this huge string and ...

Using wmemset in c++

While using wmemset api (http://msdn.microsoft.com/en-us/library/1fdeehz6(VS.80).aspx) for the count parameter should I have to multiply the length of the target string by 2 and provide or will wmemset will itself take care of the conversion? ...

Converting System::String to Const Char *

I am using Visual C++ 2008's GUI creator to make a user interface. When a button is clicked, the following function is called. The content is supposed to create a file and name the file after the contents of the textbox "Textbox' with '.txt' at the end. However, that leads me to a conversion error. Here is the code: private: System::Vo...

sequential strpos() faster than a function with one preg_match?

i need to test if any of the strings 'hello', 'i am', 'dumb' exist in the longer string called $ohreally, if even one of them exists my test is over, and i have the knowledge that neither of the others will occur if one of them has. Under these conditions I am asking for your help on the most efficient way to write this search, strpos(...

split a string in python

All, I have a string in python say a="Show details1\nShow details2\nShow details3\nShow details4\nShow details5\n" How do we split the above with the delimiter \n (a newline). The result should be as ['Show details1', 'Show details2', ..., 'Show details5'] ...

Ruby Convert String to File

Is it possible to convert a string to a file without writing it to disk? I would like to work ubiquitously with either a string of a file: input = "123" if (ARGV.length == 1) input = File.open(ARGV[0]) #do stuff with input Can I create a file from a string (without writing to disk)? Otherwise, I would not be able to do input.read...

Use arguments as variable names in objective-c

Hi, I'm new at objective-c and stuck with a problem. Is it possible to take an argument of a function to use as some variable names? For example, say I have a bunch of image: aPic1, aPic2, bPic1, bPic2, cPic1, cPic2, and I want to create an action so that every time when a button is clicked, the view controller will hide Pic1 and displ...