string-manipulation

Is there a better/more pythonified way to do this?

I've been teaching myself Python at my new job, and really enjoying the language. I've written a short class to do some basic data manipulation, and I'm pretty confident about it. But old habits from my structured/modular programming days are hard to break, and I know there must be a better way to write this. So, I was wondering if any...

C# string splitting

If I have a string: str1|str2|str3|srt4 and parse it with | as a delimiter. My output would be str1 str2 str3 str4. But if I have a string: str1||str3|str4 output would be str1 str3 str4. What I'm looking for my output to be like is str1 null/blank str3 str4. I hope this makes sense. string createText = "srt1||str3|str4"; string[] tx...

Ant string functions?

Does Ant have any way of doing string uppercase/lowercase/captialize/uncaptialize string manipulations? I looked at PropertyRegex but I don't believe the last two are possible with that. Is that anything else? ...

Reading in certain lines of a text file

Yes, I have already asked this question, but the problem is much more specific. Last time I wanted to ignore the first 2 and the last line of the file. But it struck me that anyone could put as many lines as they wanted before and after the stuff I want to read in, and in that case, the code I've implemented goes to pot. example file ...

C# Textbox string separation

Hi, I have textbox in c#, contains two or three strings with white spaces. i want to store those strings seperately.please, suggest me any code. thanx. ...

Is it possible to convert an array of strings into one string?

In my program, I read in a file using this statement: string[] allLines = File.ReadAllLines(dataFile); But I want to apply a Regex to the file as a whole (an example file is shown at the bottom) so I can eliminate certain stuff I'm not concerned with in the file. I can't use ReadAllText as I need to read it line by line for anothe...

Python Titlecase a String with exceptions

Is there a standard way in Python to titlecase a string (i.e. words start with uppercase characters, all remaining cased characters have lowercase) but leaving articles and like lowercased? ...

In C# is there a slick way to switch two sections of a string that are divided by a comma?

I have a bunch of lat/long pairs as a string: -94.5555,95.5555 The API I'm using requires they be switched: 95.555,-94.555 Is there any slick, short way of doing this? ...

How do I find variables in a string?

I receive leads via email when someone submits a form residing on a website on which I pay to advertise. Using PHP, I can access my email account (IMAP), get and read messages, but I'm having trouble extracting certain information from the body of the email. I can explode (\n) the body but cannot figure out how to extract the needed in...

Serialize a HashSet<String> with LinQ

I'd like to take a HashSet<String> and elegantly convert it to a string. I can iterate like so: HashSet<String> words = new HashSet<string>() { "alpha", "beta", "delta" }; string joined = ""; foreach (var w in words) joined += w + ","; if(joined.Length > 0) joined = joined.SubString(0,joined.Length-1); // remove final comma Is ...

Is NSMutableString's -appendString: method an efficient way to build up a large string?

I'm planning on building up a potentially large string by iterating over a collection and generating chunks at a time. If I were to simply start with an NSMutableString and repeatedly append chunks to it, does that work reasonably efficiently or is it a Schlemiel the Painter situation? It seems plausible to me that NSMutableString is imp...

How to convert a string representing decimal number in exponential form to float in Qt?

I have some decimal numbers in a text file represented in exponential form Eg: 144.2e-3. I want to store the values in float. In qt it returns "0" when i directly use the "number.toFloat()" method. Please help. ...

String chomping match expression with bound variable

Hi, The following shell sessions shows some behavior I would like to understand: 1> A = "Some text". "Some text" 2> "Some " ++ R = A. "Some text" 3> R. "text" 4> B = "Some ". "Some " 5> B ++ L = A. * 1: illegal pattern Surely statements 2 and 5 are syntacticially identical? I would like to use this idiom to extract some text from a s...

remove all occurence of anchor tags from a string without removing thier child node

I have an html string and I need help transforming this: <table > <tr> <td><a href="/link.html" onclick="javascript:aFunction()">some text</a></td> <td><a href="/anotherlink.html">some more text</a></td> </tr> </table> to this: <table > <tr> <td>some text</td> <td>some more text</td> ...

Why does this C++ program print irrelevant characters?

Hey i am new to programming in C++, and i get the hang of it but i got stuck on this one simple problem i am suppose to create a shift cipher using the letters A-Z and shifting them 3 places, i get everything but when i do my output i get extra letters that are unneeded like "|[|" i know i have to put a terminator and i did but doesn't s...

Android Split string.

i have a string called CurrentString and is in the form of something like this "Fruit: they taste good". i would like to split up the CurrentString using the : as the delimiter.so that way the word "Fruit" will be split into its own string and "they taste good" will be another string.and then i would simply like to use SetText and 2 dif...

In Perl, how can I print lines read from a file with optional leading whitespace removed?

#!/usr/bin/perl open(SARAN,"first.txt") or die "Can't Open: $!\n"; while($line=<SARAN>) { print "$line\n"; } close SARAN; Hi, In the above perl script, i need one functionality... in first.txt, each line starts with some space in front.. I need to print the lines without space in front... What to do. thanks.. ...

Why does this program give segmentation fault?

Hi, It's a beginners question: Why is this breaking/giving an error? #include <stdio.h> #include <stdlib.h> #include <string.h> char *strtrim_right(char *p) { char *end; int len; len = strlen( p); while (*p && len) { end = p + len-1; if(isalpha(*end)) *end =0; else break; } return(p);...

Displaying bandwidth speed in a user-friendly format

Hi guys, I'm looking for a string conversion method that will receive an input of KB/s and converts it to the easiest readable format possible. e.g. 1500 b/s = 1.46 Kb/s e.g. 1500 Kb/s = 1.46 Mb/s e.g. 1500 Mb/s = 1.46 Gb/s Thanks ...

Removing String double-quotes in Haskell

This function generates simple .dot files for visualizing automata transition functions using Graphviz. It's primary purpose is debugging large sets of automatically generated transitions (e.g., the inflections of Latin verbs). prepGraph :: ( ... ) => NFA c b a -> [String] prepGraph nfa = "digraph finite_state_machine {" :...