string-manipulation

How do I replace multiple spaces with a single space in C#?

How can I replace multiple spaces in a string with only one space in C#? Example "1 2 3 4 5" would be : "1 2 3 4 5"? ...

The origin of sprintf-style string formatting

The string formatting concept found in sprintf can be found in almost any language today (you know, smothering a string with %s %d %f etc. and providing a list of variables to fill their places). Which langugage was it originally that had a library function or language construct which offered this functionality? Please specify some ki...

String Manipulation in MS SQL Server

Can anyone give me a complete list of string manipulation function in Microsoft SQL Server (2000 or 2005)? (I don't need a lecture about doing all my string processing in the presentation layer. And, I don't need a list of MySQL string functions.) Thanks! ...

Adding a newline into a string in C#

I have a string. string strToProcess = "fkdfdsfdflkdkfk@dfsdfjk72388389@kdkfkdfkkl@jkdjkfjd@jjjk@"; I need to add a newline after every occurence of "@" symbol in the string. My Output should be like this fkdfdsfdflkdkfk@ dfsdfjk72388389@ kdkfkdfkkl@ jkdjkfjd@ jjjk@ ...

String contains in bash

Using bash, I have a string: string=`echo My string` How can I test if it contains another string? if [ $string ?? 'foo' ] then; echo "It's there!"; fi; Where ?? is my unknown operator. Do I use echo and grep? if [ `echo $string || grep 'foo' ` ] then; echo "It's there!"; fi; That looks a bit clumsy. ...

Jython Spliting String Up

Hi, I am trying to manipulate a string using Jython, I have included below an example string: This would be a title for a website :: SiteName This would be a title for a website :: SiteName :: SiteName I am trying to remove all instances of ":: Sitename" or ":: SiteName :: SiteName", can anyone help me out? Cheers ...

std::string erase last character fails?

I'm trying to change user input in wildcard form ("*word*") to a regular expression format. To that end, I'm using the code below to strip off the '*' at the beginning and end of the input so that I can add the regular expression characters on either end: string::iterator iter_begin = expressionBuilder.begin(); string::iterator i...

Replace Line Breaks in a String C#

How can I replace Line Breaks within a string in C#? ...

How do you convert a string to a byte array in .Net

I have a string that I need to convert to the equivalent array of bytes in .NET. This ought to be easy but I am having a brain cramp. ...

Algorithm to find similar text

I have many articles in a database (with title,text), I'm looking for an algorithm to find the X most similar articles, something like Stack Overflow's "Related Questions" when you ask a question. I tried googling for this but only found pages about other "similar text" issues, something like comparing every article with all the others...

How do I remove diacritics (accents) from a string in .NET?

I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert é to e.) What is the best method for achieving this? ...

Pattern matching and placeholder values

Language: C# Hello, I'm writing an application that uses renaming rules to rename a list of files based on information given by the user. The files may be inconsistently named to begin with, or the filenames may be consistent. The user selects a list of files, and inputs information about the files (for MP3s, they would be Artist, Tit...

Slicing URL with Python

Hi. I am working with a huge list of URL's, you guys have already helped me :) Just a quick question I have trying to slice a part of the URL out, see below: http://www.domainname.com/page?CONTENT_ITEM_ID=1234&param2&param3 How could I slice out: http://www.domainname.com/page?CONTENT_ITEM_ID=1234 Sometimes there is more ...

Create NSString by repeating another string a given number of times

This should be easy, but I'm having a hard time finding the easiest solution. I need an NSString that is equal to another string concatenated with itself a given number of times. For a better explanation, consider the following python example: >> original = "abc" "abc" >> times = 2 2 >> result = original * times "abcabc" Any hints? ...

Replace non-numeric with empty string

Quick add on requirement in our project. A field in our DB to hold a phone number is set to only allow 10 characters. So, if I get passed "(913)-444-5555" or anything else, is there a quick way to run a string through some kind of special replace function that I can pass it a set of characters to allow? Regex? ...

String manipulation with Excel - how to remove part of a string if another part is there?

I've done some Googling, and can't find anything, though maybe I'm just looking in the wrong places. I'm also not very adept at VBA, but I'm sure I can figure it out with the right pointers :) I have a string I'm building that's a concatenation of various cells, based on various conditions. I hit these in order. =IF(A405<>A404,G405,G40...

How to find two adjacent repeating digits and replace them with a single digit in Java?

I need to find two adjacent repeating digits in a string and replace with a single one. How to do this in Java. Some examples: 123345 should be 12345 77433211 should be 74321 ...

Best way to strip punctuation from a string in Python

It seems like there should be a simpler way than: import string s = "string. With. Punctuation?" # Sample string out = s.translate(string.maketrans("",""), string.punctuation) Is there? ...

How can I do string operations in XSLT?

I have the following code block in my xslt; <xsl:when test="StatusData/Status/Temperature > 27"> <td bgcolor="#ffaaaa"> <xsl:value-of select="StatusData/Status/Temperature" /> </td> </xsl:when> But as you might guess when the value is 34,5 instead of 34.5 it is recognis...

How do you convert multistring to/from C# string collection?

Multistrings (double null-terminated string of null-separated strings) are common in the Windows API. What's a good method for converting a multistring returned from an API to a C# string collection and vice versa? I'm especially interested in proper handling of character encoding (Windows XP an later). The following method seems to be...