string

strcspn() stopping at a period

Hi. I'm writing a function that should parse a string containing a description of a dice roll, for instance "2*1d8+2". I extract the four values OK when they are integers, but I want to be able to use floats as well for the multiplier and the addition at the end. Things get nasty when I try to parse such a string: "1.8*1d8+2.5". I have ...

How to store a string in image type column in SQL Server Using SqlParameter

I have a SQL Server database, and I want to store in image type column some string. I'm trying to do the following : SqlParameter myparam = new SqlParameter("@myparam", "VeryLongString"); myparam.SqlDbType = SqlDbType.Image; when I add it to the command and then execute it, I get the following error : Failed to convert paramete...

.gsub erroring with non-regular character 194

I've seen this posted a couple of times but none of the solutions seem to work for me so far... I'm trying to remove a spurious  character from a string... e.g. "myÂstring here Â$100" should be "my string here $100" I've tried string.gsub(/\194/,'') string.gsub(194.chr,'') string.delete 194.chr All of these still leave the  in...

How to prevent copying a wild pointer string

My program is crash intermittently when it tries to copy a character array which is not ended by a NULL terminator('\0'). class CMenuButton { TCHAR m_szNode[32]; CMenuButton() { memset(m_szNode, '\0', sizeof(m_szNode)); } }; int main() { .... CString szTemp = ((CMenuButton*)pButton)->m_szNode; // sometime it crashes he...

I want to find the strings that repeated more than 1 times

dear all I have an array of strings. Some of The strings are similar (for example, person is similar to twolegperson, animal is similar to animalgold). I want to find the strings that are repeated more than 1 times (here person,animal). Thank you very much faty ...

String Encryption with JASYPT - Java

I want to encrypt a string, but the standard java libraries are too complicated for me. So i turned to JASYPT, Its pretty simple to use and understand, However when i import the library to Eclipse 3.6 and when i try encrypt a string like "Hello" with the password "123". It always comes up with an error. I'm not sure what im doing wrong b...

RegEx with strange behaviour: matching String with back reference to allow escaping and single and double quotes

Hi, community. Matching a string that allows escaping is not that difficult. Look here: http://ad.hominem.org/log/2005/05/quoted_strings.php. For the sake of simplicity I chose the approach, where a string is divided into two "atoms": either a character that is "not a quote or backslash" or a backslash followed by any character. "(([^"...

Using strings to identify objects: what's the purpose ?

OGRE3D for example uses strings to identify objects, so each time the code does something on an object using its name (a string), it has to do string operations, and since a 3D engine is very sensitive on speed, how can it be a good way on doing it ? When a computer has to do operations on a string, it does it sequentially, bytes after ...

Microsoft Interview Question : Write an efficient string matching program for string matching ?

Write a time efficient C program that takes two strings (string a, string b) and gives the first occurence of string b in string a. ...

How can I remove a specific character from a string in Perl?

I'm trying to remove a specific character from a string in Perl: my $string="MATTHATBAT"; substr($string, 2, 1, ''); EDIT: This does work, sorry. Leaving this here in case someone needs to know how to do this. Also, is there a more efficient way of doing this? The string should now be MATHATBAT. Am I missing something? I know tha...

How to display dynamically the previous month name.

I want to display the previous month name. My code is given below but it displays the index of that month. I want the name of that month. According to this given code it dipslays the tool tip as "Balance up to 9", but I want to display "Balance up to September". How get the name of that month? lblPreviousBalance.ToolTip = "Balance up t...

looking for tool that format and escape long text string to valid c char*

Hello all i looking for a tool that takes long text string to valid const char *fmt for example i want to set char* with this java script as string: http://code.google.com/p/swfobject/link text in simple words i need to properly escape the java script string so i could printf() it later i hope now its clear Thanks ...

ANTLR AST building: root node as string instead of character

I might be asking a stupid/basic question but i had been confused about ANTLR AST building. What i want to made is a kind of Boolean expression parser such that on parent nodes i have operator and its operands as children. for instance, a sentence ( ( A B C & D ) | ( E & ( F | G ) ) ) should ideally be representing |...

common java-function to create Maps from strings

Is there any common function (in apache commons or similar) to make maps from query-parameter-like strings? To specific: Variant a (Querystring) s="a=1&b=3" => Utils.mapFunction(s, '&', '=') => (Hash)Map { a:1; b:3 } Variant b (Cachecontrol-Header) s="max-age=3600;must-revalidate" => Utils.mapFunction(s, ';', '=') => (Hash)M...

error: Object reference not initialised ....

I have the following code in C#: IList<string> myList = null; myList.Add(temp); temp is a string that is decalred elsewhere and is not null (I checked it). I keep getting the following error at the line myList.Add(temp); "Object reference not initialised to an instance of an object" What am I doing wrong here??? Updating the quesit...

How to parse time range input?

Hi all, In a program I'm working on, i need the user to input time ranges, such as 2002-2003, or 1999- (implied present), or -2000 (before 2000). I have an ArrayList of objects, and so the user might put it the title of books, including some information (one of these must be the date it was published). They can then search for a spec...

Process escape sequences in a string in Python

Sometimes when I get input from a file or the user, I get a string with escape sequences in it. I would like to process the escape sequences in the same way that Python processes escape sequences in string literals. For example, let's say myString is defined as: >>> myString = "spam\\neggs" >>> print(myString) spam\neggs I want a fun...

in C what is the proper way to pass a pointer to a string from a function to the main.

this is the rough idea of what I am trying to do: I want the pointer in main to point to the word I just in my function. my actual code is very long so please excuse this format. main() { char *word; int lim 256; *word = function(word,lim)//I am not returning the address back only the first letter } function(word,lim) { //memory allo...

dealing with random numbers in php?

i want a little php function to choose a number between 0 to 5, with 50% percent chance that it will be zero, and also choose between two strings at the same time randomly: the algorithm: choose number between 0,1,2,3,4,5 randomly (50% chance for zero, 50% chance for 1,2,3,4,5) and choose string blue, yellow randomly return(number, ...

How to determine type from a given string input.

Is there any method to detect the type from a given string input? Eg: string s = "07/12/1999"; I need a method like string DetectType( s ) { .... } which would return me the matched datatype. i.e. "DateTime" in this case. Would I have to write this from scratch? Just wanted to check if anybody knows of a better way before I went abo...