string

Searching for data within a string. Regular expressions?

I have some strings I need to scrape data from. I need a simple way of telling PHP to look in the string and delete data before and after the part I need. An example is: When: Sat 19 Sep 2009 22:00 to Sun 20 Sep 2009 03:00  I want to delete the "When: " and then remove the & and everything after it. Is this a Regex thing? Not...

Cumulative Hashes

I've read before here on SO that there are some hash algorithms (I think one of those is adler32) that support the following property: adler32('abc'); // 123 adler32('def'); // 456 adler32('abcdef'); // 579 (123 + 456) Please note that the results are only examples to demonstrate what I want to archieve. I've tried some examples with ...

Regex line by line: How to match triple quotes but not double quotes

I need to check to see if a string of many words / letters / etc, contains only 1 set of triple double-quotes (i.e. """), but can also contain single double-quotes (") and double double-quotes (""), using a regex. Haven't had much success thus far. ...

How can I check if a string contains a number smaller than an integer?

Having some issue with this... if (System.Convert.ToInt32(TotalCost(theOrder.OrderData.ToString()).ToString()) < 10000) ViewData["cc"] = "OK"; else ViewData["cc"] = "NO"; yields: "Input string was not in a correct format." How can I check if the number inside the string is less than 10000? Oh yeah: TotalCost ...

Get First 6 character from string which is distinct

string[] arr = { "abcdefXXX872358", "abcdef200X8XXX58", "abcdef200X872359", "6T1XXXXXXXXXXXX11", "7AbcdeHA30XXX541", "7AbcdeHA30XXX691" }; how can I get distinct no from above where first 6 charatcer must be distinct result would be abcdefXXX872358 6T1XXXXXXXXXXXX11 7AbcdeHA30XXX541 I try something like this var dist = (from c i...

Marshalling array of strings to char ** in C#. Must be quite easy (if you know how ;-)

Hi, I'm calling a C DLL function and need to supply the following C struct: typedef struct { char *mTableId; char **mFieldNames; int mNumFields; char *mFilter; char *mSort; int mOffset; int mMaxRecords; char *mTargetRecordFilter; int mSurroundingRec...

Java Strings to Int

Hi, I'm just stuck with a problem (maybe Simple). But I can't figure out how to solve it, maybe someone of you can help me. I receive as input an string with this format: D0001001.tiff And I need to return the next one (given that the next one is the received incremente by factor of one. Input: D0001001.tiff Output: D0001002.tiff No...

A line of java code and what it does?

So I have purchased the book "Java for Dummies" 4th Edition, and I must say it is probably the best 30 dollars I have ever spent on a book. I'm not new to coding, am actually fairly decent at at it if I say so myself. However, I've come across a line of code that has me a touch confused: public void setName(String n) { if(!n.equa...

How to find the position or location of string in given document.

How to find the position or location of string in given document.I have one word document and i want to store all its words and word positions in database so thats why i need to find the position of the words. so please tell me how can i find position or location of word or string in given document. Thanks in Advance. Dhiraj ...

Trimming A Vertical Bar

Hi guys, In PHP the trim function has a parameter for trimming specific characters (handy for leading zeros and the like). I can't seem to get it to accept a vertical bar (|) character. Anyone know how to get this working? I tried the hex value but had no luck. I'm sure it's something simple. Cheers ...

Best syntax to create multi-line string

Hi! What's the best way to create multi-line string in C#? I know the following methods: Using StringBuilder var result = new StringBuilder().AppendLine("one").AppenLine("two").ToString() looks too verbose. Using @ var result = @"one two" looks ugly and badly formatted. Do you know better ways? ...

Best way to split string into lines

Hi! How do you split multi-line string into lines? I know this way var result = input.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); looks a bit ugly to me and it looses empty lines. Do you know better solutions? ...

read string from .resx file in C#

Hi How to read the string from .resx file in c#? please send me guidelines . step by step ...

Basic Ruby string handling question

Does giving a idea = gets.reverse print idea If user inputted 'dog' it would come out 'dog' But if you did this code... idea = gets.reverse! print idea Then the string variable being returned would be 'god', right? ...

How do I parse out the fields in a comma separated string using sscanf while supporting empty fields?

I have a comma separated string which might contain empty fields. For example: 1,2,,4 Using a basic sscanf(string,"%[^,],%[^,],%[^,],%[^,],%[^,]", &val1, &val2, &val3, &val4); I get all the values prior to the empty field, and unexpected results from the empty field onwards. When I remove the expression for the empty field from th...

Why is this C code giving me a seg fault?

Possible Duplicate: How to copy char *str to char c[] in C? char *token = "some random string"; char c[80]; strncpy(c, token, sizeof c - 1); c[79] = '\0'; char *broken = strtok(c, "#"); ...

cluster short, homogeneous strings (DNA) according to common sub-patterns and extract consensus of classes

Task: to cluster a large pool of short DNA fragments in classes that share common sub-sequence-patterns and find the consensus sequence of each class. Pool: ca. 300 sequence fragments 8 - 20 letters per fragment 4 possible letters: a,g,t,c each fragment is structured in three regions: 5 generic letters 8 or more positions of g's...

Problem with setting a session with data from an xml file in PHP

Howdy again Stack Overflowers, I have this feed that I want to store the session_id in that xml file as a string to play with outside the loop, what am I doing wrong? if($xmlobj = simplexml_load_string(file_get_contents($xml_feed))) { foreach($xmlobj as $listing) { echo $session_Id = $listing->session...

visual c++ copy textbox content

how to copy textbox->Text content in a char array? i m working in vc++. ...

Ruby: counting digits in a float number

Is there any worthy Ruby method to count the number of digits in a float? Also, how do I specify the precise when to_s float numbers? ...