string

How to avoid type conversion in flex from string to number ?

I am returning 12345678910111213171819 from java to flex, with in xml tags using http serivce. The result format is object. but when I display the text it automatically converted or treated as number so it displays like 1.234567891011121317181 x e^21 .... How to avoid this? Thanks in advance. Regards, Sankara narayanan Ekambaranathan....

python: comparing two strings

I would like to know if there is a library that will tell me approximately how similar two strings are I am not looking for anything specific, but in this case: a = 'alex is a buff dude' b = 'a;exx is a buff dud' we could say that b and a are approximately 90% similar. Is there a library which can do this? ...

javascript split string on multiple fields using regex

I'm trying to build a handy dsl-ish query ability into my javascript. given: var query = "lastName = 'smith' and firstName = 'jack' or city = 'vancouver'"; what's the most elegant way of parsing this sql-esque string into usable objects such as: [ { field:'lastName', operator:'=', value:'smith', join:'and' }, { field:'firstName...

Is there an equivalent of C#'s verbatim string literals in PHP ?

I know I can create a verbatim string literal in C# by using the @ symbol. For example, the usual String path = "C:\\MyDocs\\myText.txt"; can also be re-written as String path = @"C:\MyDocs\myText.txt"; In this way, the string literal isn't cluttered with escape characters and makes it much more readable. What I would like to k...

How can I return an array of strings in an ANSI C program?

How can I return an array of strings in an ANSI C program? For example: #include<stdio.h> #define SIZE 10 char ** ReturnStringArray() { //How to do this? } main() { int i=0; //How to do here??? char str ** = ReturnStringArray(); for(i=0 ; i<SIZE ; i++) { printf("%s", str[i]); } } ...

Best way to get integer part of the string "600sp"???

I have a string, say "600sp" from which I wish to obtain the integer part (600). If I do Integer.valueOf("600sp") I get an exception due to the non-numeric value "s" which is encountered in the string. What is the fastest cleanest way to grab the integer part? Thanks! ...

How is the data stored in a textbox?

I was reading this paper "Ropes: an Alternative to Strings" about ropes [figure from the same paper] and I was wondering if that is the data structure used by today's browsers to implement textboxes or not. Do we use ropes or some other data structures for this? Are ropes used somewhere besides textboxes? The previous title of m...

perl code that makes a list of all words that follow a given string in a text file

This is difficult to describe but useful in extracting data in the output I am dealing with (I hope to use this code for a large number of purposes) Here is an example: Say I have a text file with words and some special characters ($, #, !, etc) that reads: blah blah blah add this word to the list: 1234.56 blah blah blah blah b...

How to convert a date of integers to a formated date string (i.e. 2012009 to 2/01/2009)

Any ideas? I can't come up with any. I have a list of dates I'm loading in from a csv file and they are saved as all integers, or rather a string of integers (i.e. Jan 1, 2009 = 1012009) Any ideas on how to turn 1012009 into 1/01/2009? Thanks! ...

Tokenize valid words from a long string

Suppose you have a dictionary that contains valid words. Given an input string with all spaces removed, determine whether the string is composed of valid words or not. You can assume the dictionary is a hashtable that provides O(1) lookup. Some examples: helloworld-> hello world (valid) isitniceinhere-> is it nice in here (valid) zx...

IntPtr To String conversion in Windows messages

I'm getting in trouble by hooking window messages. I need to detect window text (caption) changes, so I intercept the WM_SETTEXT message for the interesting windows (I do so because at window creation the window caption is not specified). Reading the documentation of the WM_SETTEXT documentation, the lParam parameter specify a pointer t...

Sort NSMutableArray

please help me I want to sort NSMutableArray and yes I can do this by NSSortDescriptor *sortPoint = [[NSSortDescriptor alloc] initWithKey:@"point" ascending:YES]; [hightScore sortUsingDescriptors:[NSArray arrayWithObject:sortPoint]]; but in NSMuatableArray(hightScore), I have 2 NSMutableDictionary like this [item setObject:@"player_n...

Dissolve string bytes into a fixed length formula based pattern by using keys, and even extract those bytes.

Suppose there is a string containing 255 characters. And there is a fixed length assume 64-128 bytes a kind of byte pattern. I want to "dissolve" that string with 255 characters, byte by byte into the other fixed length byte pattern. The byte pattern is like a formula based "hash" or something similar into which a formula based algorithm...

std::string and its automatic memory resizing

I'm pretty new to C++, but I know you can't just use memory willy nilly like the std::string class seems to let you do. For instance: std::string f = "asdf"; f += "fdsa"; How does the string class handle getting larger and smaller? I assume it allocates a default amount of memory and if it needs more, it news a larger block of memory ...

Add string to char array in C

I have a C array called buf. Here is it's definition: char buf[1024]; Now, my current code takes from stdin and uses fgets() to set that array, however I wish to use code to set it instead. Right now the line that sets buf looks like this: fgets(buf, 1024, stdin); Basically, I want to replace stdin, with say... "My String". What's th...

Pass variable to string in include file - PHP

What I am trying to do is to have an include file with generalized language in a string that will be used across multiple pages, but I also need to pass a variable to the string from the current page. Here is an example: Here is a snippet of the index.php page: <?PHP require_once($_SERVER['DOCUMENT_ROOT'].'/lib/prefix.php'); echo $GE...

How can I speed up my 'divide and conquer' XSLT template which replaces certain characters in a string?

UPDATE: I added an answer to this question which incorporates almost all the suggestions which have been given. The original template given in the code below needed 45605ms to finish a real world input document (english text about script programming). The revised template in the community wiki answer brought the runtime down to 605ms! I...

regex remove digits and - in beginning

I'm treating a list of strings, but I want to alter the strings so they don't look ugly to the user. An example list would be 2736162 Magazines 23-2311 Numbers 1-38122 Faces 5-231123 Newspapers 31-31235 Armynews 33-12331 Celebrities 1 33-22113 Celebrities 2 Cars Glasses And what I want is to trim out the beginning so that the ugly seq...

C++ append to string and write to file

Why does the following code not work #include <iostream> #include <fstream> #include <stdio.h> #include <string.h> #include <stdlib.h> using namespace std; int main(){ string data; int i=0; while(i <= 5){ i++; data += i; data += "\n"; } ofstream myfile; myfile.open ("data.txt"); myfile <<...

Is there any reason to use this Regex method over String.IsNullOrEmpty()?

I have a method called isStringOnlyWhitespace(): public static bool isStringOnlyWhitespace(string toEval) { string stringNoWhitespace = Regex.Replace(toEval, @"\s", ""); if (stringNoWhitespace.Length > 0) return false; else return true; } Is there any reason to use this method to check for blank/null strings over String.Is...