string

Remove space before a comma in a ruby string

Hey, I am using a reg expression to remove parentheses and the content between them from a ruby string. The problem is that this sometimes leaves a space before commas. I am not sure how to go about removing this space. I've been playing around with the following but it has not been working: @char_count = 0 sentance.each_char{|char...

Can't get localized strings from xml files correctly

I've been racking my head with this... I've got a localized strings.xml file in a values-en folder with this example string: @string/my_string The string has the following text stored in English: "My String" When accessing the localized string via a layout, it works fine. When I try to change it in code, that's where I get problems. ...

ANSI C - append chars to get a string

I have the following code in C: char *str = "Hello World"; char *s = malloc(strlen(str)); int i =0; for(;i<strlen(str)-5;i++) { s += *(str+i); } printf(s); It shows nothing. What I want is to get the substring of str stored in s. In Java I would do the following: String str = "Hello World"; ...

c - get file into array of chars

hi i have the following code below, where i try to get all the lines of a file into an array... for example if in file data.txt i have the following: first line second line then in below code i want to get in data array the following: data[0] = "first line"; data[1] = "second line" My first question: Currently I am getting "Segmentat...

Passing strings to .NET Windows Service

I am writing a ASP.NET queue processor. Users will login and upload data files to the site, and then click to start processing the data files. I have a Windows Service on the system that waits for items to arrive in the queue and processes them. So far everything works except the items in the queue seem to get lost. I believe the sta...

[java] String can't change. But int, char can change.

I've read that in Java an object of type String can't change. But int and char variables can. Why is it? Can you give me an example? Thank you. (I am a newer -_- ) ...

How does std::string overload the assignment operator?

class mystring { private: string s; public: mystring(string ss) { cout << "mystring : mystring() : " + s <<endl; s = ss; } /*! mystring& operator=(const string ss) { cout << "mystring : mystring& operator=(string) : " + s <<endl; s = ss; //! return this; return (mystring&)this; // why COMPILE ERROR } */ mystring o...

checking empty string in java

Hi Geeks, I dont know whats the wroing with the below code.... I am getting input from textbox and putting the input in a string. If the textbox is empty it will return a empty string. In the below code String[] str = new String[9]; for(int i=0;i<9;i++){ if(str[i].equals("")){ System.out.println("set " + cmds[i]...

How do I generate a random string (of length X, a-z only) in Python?

How do i generate it? The string ...

AntiAlias failed when draw string with certain angle in GDI+

I am using the following code to draw Strings. In GDI+ Graphics tempFontGr(XXX); Matrix* myPathMatrix = NULL; myPathMatrix->Rotate(GetDCAngle(), MatrixOrderPrepend); cantempFontGr.SetTransform(myPathMatrix); tempFontGr.SetInterpolationMode(InterpolationModeHighQuality); tempFontGr.SetSmoothingMode(SmoothingModeAntiAlias); tempFontGr.Dr...

What is a good way of sending data as strings through sockets?

Hi As there several ways to exchange data in the form of strings over sockets, such as e.g: using functions like: 1) sprintf() and sscanf() 2) snprintf() and sscanf() 3) printf() and strtof() or converting to char and then pass it as an array I would appreciate if you could suggest which way and why is efficient and better than ot...

Java String formatting

I have a property-file with strings inside, formatted in this way: audit.log.events.purged=The audit events were purged. {0} events were purged, {1} assets were deleted. Is there a way to bind some values inside those {0} and {1}, using some standard APIs, or should I create some code for parsing those Strings? ...

C# Create multiple .txt files using strings from another file and textbox

Hello to all. I am new to programming. Is there a way to create multiple .txt files using data from another file in C#. like this: 1. we have data.txt with 100 or more strings string1 string2 string3 ... 2. we have textbox1 and textbox2 waiting for user to enter strings 3 . we need to create 100 or more files using strings from data.t...

How do I delete the last character of a particular String in Java?

For example I'm extracting a text String from a text file and I need those words to form an array. However, when I do all that some words end with comma (,) or a full stop (.) or even have brackets attached to them (which is all perfectly normal). What I want to do is to get rid of those characters. I've been trying to do that using tho...

C# Multiple String Comparision with Same Value

Hi All. Please have a look at the below case, surely that will be interesting.. if i want to assign same value to multiple objects i will use something like this string1 = string2 = string3 = string 4 = "some string"; Now what i want to do is, i want to compare string1, string2, string3 and string4 with "someotherstring"... question...

What is wrong with this statement echo '<option value='+$index+'>'+$county[$index];?

echo '<option value='+$index+'>'+$county[$index]; It is PHP code. It doesn't output what I want. Any idea? ...

Comparing string - woes in PHP

I want to allow the user to enter a coupon number in order to get a discount. After the coupon number is entered and submitted, the page reloads withe a tick showing that they have entered a correct amount. The way I'm trying to do this is displaying the tick if the coupon amount is not £0.00. But the string comparison doesn't seem to ...

strcmpi renamed to _strcmpi?

In MSVC++, there's a function strcmpi for case-insensitive C-string comparisons. When you try and use it, it goes, This POSIX function is deprecated beginning in Visual C++ 2005. Use the ISO C++ conformant _stricmp instead. What I don't see is why does ISO not want MSVC++ to use strcmpi, and why is _stricmp the preferred way, and w...

How to extract a URL from a 200 character string of words in C#, preferably using RegExp

Hi, I'd like to implement a RegExp (regular expression) that can check a string to see if it contains "http://" (i.e. it contains a URL), and then take that whole URL into a new string variable. The string I am using is not HTML, it is simply text with any arrangement of words, characters, numbers and URLs. I'd imagine I'd look for a m...

Split a large string into multiple substrings containing 'n' number of words via python

Source text: United States Declaration of Independence How can one split the above source text into a number of sub-strings, containing an 'n' number of words? I use split(' ') to extract each word, however I do not know how to do this with multiple words in one operation. I could run through the list of words that I have, and create...