string

How to continue from where I have been searching to find the index?

How to continue from where I have been searching to find the index? I am searching in a file to find the index of a character; then I have to continue from there to find the index of the next character. For example : string is " habcdefghij" int index = message.IndexOf("c"); Label2.Text = index.ToString(); labe...

How do I convert a byte array to Base64 in Java?

Okay, I know how to do it in C#. It is simple as Convert.ToBase64String(byte[]) and Convert.FromBase64String(string) to get byte[] back. How can I do this in Java? ...

Algorithm to find common substring across N strings

I'm familiar with LCS algorithms for 2 strings. Looking for suggestions for finding common substrings in 2..N strings. There may be multiple common substrings in each pair. There can be different common substrings in subsets of the strings. strings: (ABCDEFGHIJKL) (DEF) (ABCDEF) (BIJKL) (FGH) common strings: 1/2 (DEF) 1/3 (ABCDEF) 1/4...

How to convert a unicode string written in font A to font B?

Assuming all the required fonts are available on client's machine. Probably, you all could see following 'stackoverflow' word written in Indic Language script : 'स्टैकओवरफ्लो' . A quick lookup using Web Developers Tools tells that this word is written using 'Arial, Liberation Sans..' font family. Does that mean Arial font supports Indi...

"Fatal error: Cannot use string offset as an array" when variable is 08 or 09.

I'm writing a script to output Google Analytics API data and insert it into a bar chart using Google Charts API. When I have a string like this in the URL, I get the desired result. gaFeedData.php?y[]=2009&y[]=2010&m[]=1&m[]=2 However, when I have the following string in the URL, I get an error: Fatal error: Cannot use string offset ...

?? Coalesce for empty string?

If this is a duplicate please point me to it and I'll close, I couldn't find anything. Something I find myself doing more and more is checking a string for empty (as in "" or null) and a conditional operator. A current example: s.SiteNumber.IsNullOrEmpty() ? "No Number" : s.SiteNumber; This is just an extension method, it's equivale...

Python String with HTML /

I'm trying a simple program to send some html down a socket to a client. 2 things are goofing me up. The code: c.send( str.encode("<HTML><BODY>Test Page<///BODY><///HTML>") ) My python client receives: b'<HTML><BODY>Test Page<///BODY><///HTML>' According to Beginning Python which says it covers Python 3 (I'm using 3.1.1 on Window...

Search for string allowing for one mismatches in any location of the string, Python

I am working with DNA sequences of length 25 (see examples below). I have a list of 230,000 and need to look for each sequence in the entire genome (toxoplasma gondii parasite) I am not sure how large the genome is but much more that 230,000 sequences. I need to look for each of my sequences of 25 characters example(AGCCTCCCATGATTGAACAG...

Python Unicode strings and the Python interactive interpreter

I'm trying to understand how python 2.5 deals with unicode strings. Although by now I think I have a good grasp of how I'm supposed to handle them in code, I don't fully understand what's going on behind the scenes, particularly when you type strings at the interpreter's prompt. So python pre 3.0 has two types for strings, namely: str (...

Regarding Java Command Line Arguments

I have the below command line arguments set for the program. argument proc is mandatory argument chgval is optional and argument inputfile is optional. ./test.sh -proc mode1 -chval a -inputfile b.csv I need to modify the below function so that either one of the optional argument should exists in command line arguments along with ...

Reliably splitting lines out of a string

I'm writing myself a small server daemon in C, and the basic parts like processing connects, disconnects and receives are already in, but a problem in receiving still persists. I use "recv" to read 256 bytes at once into a char array, and because it can contain multiple lines of data as one big chunk, I need to be able to split each lin...

What is the best way to achieve `sscanf`-like functionality in perl?

What is the best way to achieve sscanf-like functionality in perl? I am looking now looking at the sscanf module, Which is better, Option-1: Going sscanf way? Option-2: Regex way? [I am a beginner when it comes to Regex] ...

Filter string in C

How can I filter a string in c? I want to remove anything that isn't [a-z0-9_]. int main(int argc, char ** argv) { char* name = argv[1]; // remove anything that isn't [a-z0-9_] printf("%s", name); } ...

Strings and Garbage Collection

I have heard conflicting stories on this topic and am looking for a little bit of clarity. How would one dispose of a string object immediately, or at the very least clear traces of it? ...

Rotate a string N times in PHP

I'm looking for a way to rotate a string to the left N times. Here are some examples: Let the string be abcdef if I rotate it 1 time I want bcdefa if I rotate it 2 time I want cdefab if I rotate it 3 time I want defabc . . If I rotate the string its string length times, I should get back the original string. ...

NHibernate config connection string info

What's the best way to store connection string info? I'd rather not just store the db password in NHib.config file. ...

What is the easiest way to convert list with str into list with int? =)

Hello. What is the easiest way to convert list with str into list with int in python? =) For example, we have to convert ['1','2','3'] to [1,2,3]. Of course, we can use "for:", but it's too easy =) ...

Word comparing and replacing

Hi friends, I need some comparing and replacing code in PHP Our mission is to empower consumers to Praise Good Service when they receive it and to Report Poor Service wherever they have to endure it. I need this paragraph to xcompare for some words (for example mission, Good ) and replace that word like this m***n and G**d ...

How can I replace ?myuser=number with an empty string in PHP

How can I replace a string containing a lot of ?myuser=12122 ?myuser=5457 ... with empty string so that it doesn't show ?myuser=number inside the string? I think I should use regex? ...

what is character for end of file of filestream?

i am searching in a while loop for a particular character to check whether it reached the end of file. Which character which i can search for ?? Eg: Indexof('/n') end of line Indexof(' ') end of word ???? ---------- end of file?? ...