string

Real Life, Practical Example of Using String.intern() in Java ?

I've seen many primitive examples describing how String intern()'ing works, but I have yet to see a real-life use-case that would benefit from it. The only situation that I can dream up is having a web service that receives a considerable amount of requests, each being very similar in nature due to a rigid schema. By intern()'ing the re...

stristr Case-insensitive search PHP

Hi All, Please excuse my noob-iness! I have a $string, and would like to see if it contains any one or more of a group of words, words link c*t, fu*, sl** ETC. So I was thinking I could do: if(stristr("$input", "dirtyword1")) { $input = str_ireplace("$input", "thisWillReplaceDirtyWord"); } elseif(stristr("$input", "dirtyWord1")) { ...

filesize from a String

hello! how can i get the "filesize" from a string in php? I put the string in a mysql database as a blob and i need to store the size of the blob. My solution was to create a temp file and put the string into the temp file. now i can get the filesize from the "string". but that solution is not good... greetings ...

C++ input string contain ASCII 26(Substitute) character. How to get rid of it ?

Here's my code. Purpose is to input a Vector of Student class, contain name and homework grades. istream& input(istream& is, student& s){ is.clear(); cout << "Enter student name: "; getline(is,s.name); grade(is,s.homework); return is; } istream& grade(istream& is, vector<double>& homework){ if(is){ homew...

Turn underscored names in Rails into 'pretty' text (Like ActiveRecord)

I have a real simple question here. I only want to know if there is an existing Rails way to accomplish this, because I don't want to re-write something that is already in the framework. Think of an underscored variable name like "this_is_an_example". Is there a quick way to turn that into "This is an example" or even "This Is An Exampl...

PHP Append to empty string without error.

Hey folks, I have got the following issue, my function appends code to a string $string ($string .= bla), but in the beginning the string is empty, so I get this error message A PHP Error was encountered Severity: Notice Message: Undefined variable: $string Filename: libraries/file.php Line Number: 90 Of course if I define...

How do I use a ruby regex to get a substring?

I want to get the numbers out of strings such as: person_3 person_34 person_356 city_4 city_15 etc... It seems to me that the following should work: string[/[0-9]*/] but this always spits out an empty string. ...

Delphi Error E2283 Too many local constants

Hi everyone, this is my first post here, so please be gentle if I am missing something out ;-) I am having a compilation problem with my code in Delphi 2006. I am using a static String array: fsi_names : array [0..FSI_NUM_VARS-1] of string; In a procedure I call at the start of the program, I assign values to this array. This code i...

Splitting strings/tokens

hi, Is there a better way to read tokens in a file in java? I am currently using StringTokenizer for splitting the tokens. But it can be quite inefficient in most cases as you have to read token by token. Thank you ...

Python Remove Parts of string by index.

I have a string string='texttexttextblahblah",".' and what I want to do is cut of some of the rightmost characters by indexing and assign it to string so that string will be equal to texttexttextblahblah" I've looked around and found how to print by indexing, but not how to reassign that actual variable to be trimmed. ...

About Microsoft's String Safe Functions.

WCHAR* someString = L"SomeString\n"; WCHAR s1[MAX_PATH]; // I'm sure this is right code. StringCchCopyW(s1, _countof(s1), someString); // But I'm not sure about these example. StringCchCopyW(s1 + 100, _countof(s1) - 100, someString); // Is it right? StringCchCopyW(s1 + 100, _countof(s1), someString); // Is it right? // How about these...

Python raw literal string

str = r'c:\path\to\folder\' # my comment IDE: Eclipse, Python2.6 When the last character in the string is backslash, it seems will escape the last single quote and treat my comment as part of the string. But the raw string suppose to ignore all escape characters, right? What could be wrong? thanks. ...

Check if the inputted string contains something on my list

Let's say i input "i love you". If you have typed a statement that contains a "love" word then it will do something. ...

Which one is better :pass the whole content as string or string concatination

Hi I have 20 strings each will have same package structure except class name.These string need to be passed to method as and when require. Refer the code below public static final String RECENT_MSG_ = "com.foo.xxs.RecentMessage"; public static final String PROJ_ = "com.foo.xxs.Proj"; public static final String FORECA...

PHP String Contains with Shadowbox

I'm using shadowbox to display media based on URLs from a database. Some of the media are images and some are websites and some are flash movies I wish to check if an image contains "http://" meaning it's a website (all images and flvs start with "media/"), and if it does contain http:// then I wish to display it at a different size. ...

How to know the displayed text in UILabel ?

Hi, I have an UIView containing two UILabels, in order to display a string. The first UILabel has a fixed size, and if the string is too long and can't hold in this UILabel, I want to display the maximum characters I can in the first UILabel, and display the rest of the string in the second UILabel. But to make this, I must know the ex...

Which formats are available for Keys Enum?

Hi all. I have a next problem. I need to represent a pressed keys combination in a text form. I got pressed keys from KeyEventArgs e... And when I try to use following code e.KeyData.ToString(); I got something like this: N, Control .... But I want to get Ctrl+N string. I think that must be present specific format for String.Format becau...

Need an efficient algorithm to implement String.replaceAll()

I found String.replaceAll() in Java with regular expression underlying. It works fine in short string. But in case of long string, I need a more efficient algorithm instead of String.replaceAll(). Anyone could give advice? Thanks! ...

What is the standard algorithm for converting unicode characters into lowercase?

I want to know the standard algorithm for converting unicode characters into lowercase as proposed by unicode.org. Also, do most programming languages follow this proposed standard? ...

javascript: split string straight to variables

I'd like to know if standard JS provides a way of splitting a string straight into a set of variables during their initial declaration. For example in perl I would use: my ($a, $b, $c) = split '-', $str; In Firefox I can write var [a, b, c] = str.split('-'); But this syntax is not part of the ECMA standard and as such breaks in all...