string

Why doesn't a string builder exist everywhere?

I sort of understand the motivation for a String Builder class, but do all languages have one? Should they? I'm thinking specifically of PHP, Perl, Python, and Ruby. I know C# and Java do. If the others don't, why not? Do they not suffer from the same implementation problem? Or do they not care? ...

Converting a UNICODE_STRING to ANSI or vice versa in C

Hello, I have a UNICODE_STRING that I would like to compare to a null-terminated ANSI string to check if they are the same. I'm using C. I would like to avoid including winternl.h for RtlInitUnicodeString. What is the preferred method doing this? Or, alternatively, is there any problem with me using MultiByteToWideChar() to conve...

How can a StringBuilder best be converted to a String[]?

The following code sort of works, but fixes the number of elements in String[]. Is there a way to make a String[] add the number of elements needed dynamically? private static StringBuilder names = new StringBuilder(); ... public String[] getNames() { int start = 0; int end = 0; int i = 0; String[] nameArray = {"","","",...

Comparing string distance based on precomputed hashes

I have a large list (over 200,000) of strings that I'd like to compare to a given string. The given string is inserted by a user, so it may be slightly incorrect. What I was hoping to do was create some kind of precomputed hash on each string on adding it to the list. This hash would contain information such as string length, addition...

TSQL, case, convert, replace end.

Need help understanding what I am doing with the syntax here, please help! I not only need to convert from float to decimal but I also need to override the original data being migrated to the same format and data (in this case) where necessary to match the newer data. ,CASE WHEN fInvReqMargin IS NOT NULL THEN (CONVERT(DECIM...

Can't get Facebook multi-friend-selector working in Facebox

I'm trying to place the Facebook multi-friend-selector in a Facebox (don't want to use fb:dialog as it pops a new window). The problem I'm having probably stems from escaping quotation marks in javascript, but I've been banging my head against the wall trying to figure it out. Is there a better way to do this? $('#test_button').click(...

Comparison of substring operation performance between .NET and Java

Taking substrings of a string is a very common string manipulation operation, but I heard that there might be considerable differences in performance/implementation between the Java and .NET platform. Specifically I heard that in Java, java.lang.String offers constant time operation for substring, but in .NET, System.String offers linear...

Light C data structures and strings library?

I'm searching for something on the level of GNU extensions for C, but a little beyond (some basic data structure management). Best would be something BSD/MIT licensed. If there is something for just strings containing GNU extensions equivalents plus adding some more it would be great. I would prefer something that can be simply compile...

Writing an array as a comma separated list to screen

Now it seems like a really simple question and I may just be being thick, but what I'm trying to achieve is basically print an array to screen in the following format: Item 1, Item 2, Item 3, Item 4 Although I say to screen, as that was the best way I could describe it, I'm actually writing it to the page inside some Javascript. The w...

String constants in Ruby

In Python >>> import string >>> string.uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' or >>> string.digits '0123456789' Is there a way to use a string constant in Ruby? ...

Split strings error whats wrong with it

//Seperate into arrays NSString *NumberItems = [RawMessage componentsSeparatedByString:@"|"]; //Create the strings NSString *number1 = [NumberItems objectAtIndex:0]; NSString *number2 = [NumberItems objectAtIndex:1]; NSString *number3 = [NumberItems objectAtIndex:2]; NSString *number4 = [NumberItems objectAtIndex:3]; NSString...

How to assign a value to a variable when writing the value takes multiple lines (python)

I have a variable x to which I want to assign a very long string. Since the string is pretty long I split it into 10 substrings. I would like to do something like this: x = 'a very long string - part 1'+ 'a very long string - part 2'+ 'a very long string - part 3'+ ... 'a very long string - part 10' But tur...

How optimize this regex?

My tool gets a plain text and gradually generates the "tags" by replacing a terms from text in tags. Due to existence of some compound terms, the only way (i think) is use ReplaceAll regex. Thanks to the friends of stackoverflow, in my last question i got a excellent regex to my app, but after a tests, emerged a new need: "A regex ...

Convert DateTime to string format("yyyyMMdd")

i am having a problem converting a datetime which is in string format but iam not able to convert it to yyyyMMdd format. my code is : string tpoc = refSubClaim.BenefitsFolder.BenefitFolderIdNumber.ToString(); string[] tpocinfo = Regex.Split(tpoc,";"); for (int i = 0; i < ...

array stored as string back into array?

hello - just trying to add some setting for the admin in a database entry. i've saved; array('aviva'=>'aviva','teacher'=>'teacher'); into the field 'fullPara' but can't seem to get it back into an array? Just spits it out as a string and i've tried eval but not sure where to go from here? echo $userTypes['fullPara']; // spits out a...

Substitute {0}, {1} .. {n} in a template with given varargs

Consider a string template of the following format: String template = "The credentials you provided were username '{0}' with password '{1}'"; Substitution variable fields are of the form {n}, where n is a zero based index. This is the template format used in Adobe Flex, see StringUtil.substitute(...). And also .NET, IIRC. Since I wa...

Pattern matching variables in a case statement in Haskell

If I compare a string literal to a string literal using the case statement, I get the expected behavior: if they are the same - it matches, if they are not - it does not. However, if I compare a string literal to a constant that is a string, I get "Pattern matches are overlapped" warning and the branch with the constant always matches. ...

Jquery: How to see if string contains substring

I have a shoppingcart that displays product options in a dropdown menu, and I want to make some other fields on the page only visible if they select "Yes" in the previous option. The problem is that the shopping cart also includes the price modifier in the text, and that can be different for each product. So if I do this it works: $(...

String Stream in C

print2fp(const void *buffer, size_t size, FILE *stream) { if(fwrite(buffer, 1, size, stream) != size) return -1; return 0; } How to write the data into string stream instead of File stream? ...

PHP Find All Combinations

Hi all, I'm trying to find all possible combinations of a word, and have certain letters replaced. So, I have the following code: <form name="search" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="searchterm" /> <input type="submit" value="Submit"/> </form> <?php function pset($array) { $re...