string-manipulation

Is comparing string sizes an acceptable alternative to comparing characters?

I'm writing a grep function in C++ (as a self assigned exercise - I realize this doesn't have the functionality of an actual grep feature) to take an original string and the search string you are looking for. In the code, I enter all the characters in a grep string up to the first space it sees. Then I compare the characters in the grep ...

SQL Separate String

Duplicate Separate String with separator #@# The string below I have to call three times using sql. String: JAN#@#PIET#@#HENK The first call shoudl return: JAN The second call: PIET The third: HENK So we could use the #@# as separator but it could be that the string is: JAN#@#PIET only. Still all three calls will be done wher...

Matching an approximate string in a Core Data store

Hi everyone. I have a small problem with the core data application i'm currently writing. I have two differents models, contexts and peristent stores. One is for my app data, the other one is for a website with relevant infos to me. Most of the time, I match exactly one record from my app to another record from the other source. Someti...

Converting UUIDs from one format to another

I have an SQL document formatted as so (It has about 3000 entries like so): INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('99b857afcb2e4f7dbf8657ea916ad9d7',FALSE,'SPACE') INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('df8480e333c044f08ada939c66fa13f5',FALSE,'AIR') INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) ...

splitting string based on values in an array

I've got a group of strings which I need to chunk into an array. The string needs to be split on either '/', ',', ' with ', or '&'. Unfortunately it is possible for a string to contain two of the strings which needs to be split on, so I can't use split or explode. For example a string could say 'first past/ going beyond & then turn', ...

SQL server string manipulation in a view... Or in XSLT

I have been passed a piece of work that I can either do in my application or perhaps in SQL: I have to get a date out of a string that may look like this: 1234567-DSP-01/01-VER-01/01 or like this: 1234567-VER-01/01-DSP-01/01 but may look like this: 00 12345 DISCH 01/01-VER-01/01 XXX X XXXXX Yay. if it is a "DSP" then I want that ...

How to get the number of times a string is repeated in PHP

In a string like "abc fox fox fox ghi xyz" how can i get the number of times 'fox' is repeated in the string? ...

replacing multiple identical characters with one in a string

I have a string as follows; dim str as string = "this is a string . " I want to identify those multiple space chars and replace with one space char. using the replace function will replace all of them, so what is the correct way of doing such task? ...

Why does the compiler have a problem with this line of code?

The entire solution builds fine in Visual Studio, but when I run the Nant script to compile the website I get several errors on this line: string[] qs = (Request.QueryString["e"] ?? String.Empty) .Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries); First one says Type Expected, then Syntax error (value expected...

how do I elegantly format string in C++ so that it is rounded to 6 decimal places and has extra '0's or '9's trimmed

How do I write a function that formats a string with decimals digits, without trailing 0's or unnecessary 9's? Given that decimals is 2, here's what I expect: 0.999 -> 1.0 0.99 -> 0.99 1.01 -> 1.01 1.001 -> 1.0 123 -> 123.0 0 -> 0.0 0.1 -> 0.1 (negatives as you'd expect) Here's what I have so far, but it's pretty ugly code. Is ther...

ASP.NET: Bold words in text on image

I'm trying to dynamically write text to an image, but I would like to boldface a selected word in the sentence. What I did is separate the string into three strings, the first part, the word to be boldfaced, and the remainder of the sentence. When I attempt to draw them onto the image (.DrawString()), however, they don't concatenate, but...

Algorithm faster than BMH (Boyer–Moore–Horspool) Search

Which algorithm would you use to search short substrings in short texts? By short I mean 5-10 characters for substring and 255 for the string. I'm thinking about choosing algorithm depending on input data length. Which algorithm is better for longer inputs? ...

Numeric Format String : double to time

Hi I have a double value in seconds and i would like to use a Numeric Format String to display it as mm:ss or hh:mm:ss. Is this possible? Havent found anything about it on MSDN? The reason is that we use a Telerik Chart that displays our data and since I cant change the uderlying format I have to hook the format string into their char...

how to remove "," from a string in javascript

original string is "a,d,k" I want to remove all "," and make it to "adk". I tried: "a,d,k".replace(/,/,"") but it doesn't work. Thanks in advance. ...

Anagrams finder in javascript

I am supposed to write a program in JavaScript to find all the anagrams within a series of words provided. e.g.: "monk, konm, nkom, bbc, cbb, dell, ledl, llde" The output should be categorised into rows: 1. monk konm, nkom; 2. bbc cbb; 3. dell ledl, llde; I already sorted them into alphabetical order i.e.: "kmno kmno bbc bbc dell dell" ...

With C# which one is faster - System.Convert.ToString( objThatIsString) or (string)objThatIsString ?

or objThatIsString.ToString() as it was pointed out in the aswers .. Faster not wiser .. ...

how to get the Directory from Full path in C#?

Hi, i have a Full path as given below... C:\Users\Ronny\Desktop\Sources\Danny\kawas\trunk\csharp\ImportME\XukMe\bin\Debug\DannyGoXuk.DTDs.xhtml-math-svg-flat.dtd No i just want the DTDs directory to be fetched from this whole part? Can i use String methods in this? If yes then how to fetch this directory? Thanks for your help.... R...

How to capitalize the first character of each word, or the first character of a whole string, with C#?

I could write my own algorithm to do it, but I feel there should be the equivalent to ruby's humanize in C#. I googled it but only found ways to humanize dates. Examples: A way to turn "Lorem Lipsum Et" into "Lorem lipsum et" A way to turn "Lorem lipsum et" into "Lorem Lipsum Et" ...

C# String Manipulation using Regular Expressions

My application collects HTML content provided by internal users that is used to dynamically build articles on company web site. I want to implement a feature whereby users can surround a word/phrase in the HTML content with a special tag called <search>....</search> and when the content is saved in the database, the application will con...

Change filename extension in basic (for OpenOffice macro)

I am trying to change a filename extension in a macro for OpenOffice. My files are named like "file.odt" and I need to transform this string to "file.pdf". I use a macro that I have found on the Web but I have never written any line of basic code in my life ... However, the code is buggy and only works for 3 chars extensions (like ".do...