string-manipulation

How to delete certain characters of a word in c#

I have a string word = "degree/NN"; What I want is to remove the "/NN" part of the word and take only the word "degree". I have following conditions: The length of the word can be different in different occasions. (can be any word therefore the length is not fixed) But the word will contain the "/NN" part at the end always. How c...

String Class Methods Most Commonly Used

Any programming language. I'm interested in knowing what top 5 methods in a string class are used on data manipulations. Or what top 5 methods does one need to know to be able to handle data manipulation. I know probably all the methods together should be used, but I'm interested to see the 5 most common methods people use. Thanks for y...

Suggestions to improve a C ReplaceString function?

Hi, I've just started to get in to C programming and would appreciate criticism on my ReplaceString function. It seems pretty fast (it doesn't allocate any memory other than one malloc for the result string) but it seems awfully verbose and I know it could be done better. Example usage: printf("New string: %s\n", ReplaceString("great",...

Unexpected pointer randomly changes. Why would it change for? Breaks pointer arithmetic.

Hello. Maybe I'm being stupid but I can't figure out why a pointer is being changed in this function. I have included "printf" and "puts" to show the problem. The left braket pointer is changing and invalidates the pointer arithmetic I want to do for string manipulation. Another question I have - Is it dangerous to expect char pointers ...

Escape curly brace '{' in String.Format

How do I display a literal curly brace character when using the String.Format method? Example: sb.AppendLine(String.Format("public {0} {1} { get; private set; }", prop.Type, prop.Name)); I would like the output to look like this: public Int32 MyProperty { get; private set; } ...

PHP: String format replace and add character

Hi, I have this code: $array[] = "<b> FLYDANNA&reg; HEADWRAP </b> <ul> <li type=\"circle\"><i> Sensational headwrap made from 6 pieces of fabric to fit the contours of your head perfectly </i> <li type=\"circle\"><i> Strong yet lightweight cotton wrap can be folded up and stored almost anywhere-;pocket, purse, backpack ... y...

jQuery capitilize first letter each word

I have been using jQuery address plugin and it passes an event.value which might result in /messages/inbox/. I want to be able to turn that into Messages Inbox. I am not sure which regex to use and how to do this. Currently I have this, but this is just way too messy for me. var href = event.value != '/' ? event.value : '/wall/'; var ...

How to reverse individual words?

I need to transform a string such as "my name is thomos" to "ym eman si somoht". What do I need to know in order to do that? ...

how to check all conditon in a string.

i want to check lot's of thing in a string like i want to check 35 times different differnet index of on a string like string = "i am steven" i want to check that string have i or am and steven and some other thing. if i use indexof on this that code look like ugly then how i can apply all index of on string. ...

[Javascript]Regex Expression

Hi, I have this string: Tue,Sep,21,15:48:1,CEST,2010 I would replace the "," with a space. I have tried: string=string.replace("/,/g"," "); and the result is: Tue,Sep,21,15:48:1,CEST,2010 I have tried: string=string.replace(","," "); and the result is: Tue Sep,21,15:48:1,CEST,2010 How can I replace all the "," with " "? ...

Identifying all the nouns in a string with RoR

I need a helper that can identify all the nouns on a string. If the given string is I really enjoy eating tomatoes I should have, as result really, enjoy, and tomatoes If there is a way that I can also idetify the verbs, should be great! ...

Split parameters from ExecutionLog in SSRS (String Functions)

Hello, "Yet another string function" question for TSQL. The ExecutionLogStorage table in the ReportServer$InstanceName database for SSRS 2008 puts all parameters called to the report in a single column - FullName=LastName, FirstName&CalledBy=Lastname, FirstName&DateSelected=MM/DD/YY&CheeseorFries=Fries Some are null values, so the u...

Javascript string replace with regex to strip off illegal characters

Need a function to strip off a set of illegal character in javascript: |&;$%@"<>()+, This is a classic problem to be solved with regexes, which means now I have 2 problems. This is what I've got so far: var cleanString = dirtyString.replace(/\|&;\$%@"<>\(\)\+,/g, ""); I am escaping the regex special chars with a backslash but I am h...

String reversal in C++

I am trying to reverse the order of words in a sentence by maintaining the spaces as below. [this is my test string] ==> [string test my is this] I did in a step by step manner as, [this is my test string] - input string [gnirts tset ym si siht] - reverse the whole string - in-place [string test my is this] - reverse t...

how to validate a safe filename with double (.) (.) "fileName ..pdf"

Im sarching how to create a safe filename in my webapplication I had read a lot of post around here last one http://stackoverflow.com/questions/62771/how-check-if-given-string-is-legal-allowed-file-name-under-windows but I can't find the solution for this example when the filename comes in the way "fileName ..pdf" (double dot), the brows...

Replace string "white-spaces" with "comma" and remove all but 5 first words

Need a little help with string formatting... I have a string like this: Bmw m3 fully equipped and low mileage I need to replace whitespaces with commas, and also at the same time remove all special characters (all non number non letter characters except swedish å ä ö) Then I need to remove all but the first 5 words, or you could say ...

How can I easily remove the last comma from an array?

Let's say I have this: $array = array("john" => "doe", "foe" => "bar", "oh" => "yeah"); foreach($array as $i=>$k) { echo $i.'-'.$k.','; } echoes "john-doe,foe-bar,oh-yeah," How do I get rid of the last comma? ...

C# compare two strings for matching words.

I have two strings containing letters and numbers separated by spaces. ex "elza7ma wa2fa fel matab" and "2ana ba7eb el za7ma 2awy 2awy" What is the fastest way to compare this two string to find out whether or not they have a word in common? I tried to split one of them using string.split and use string.compare on the whole array of w...

Extract first sentence from string of text

Is there a simple trick to isolate the first sentence in a large string of text? (Perhaps using regular expressions.) Searching for the first fullstop "." doesn't work, as acronyms such as "U.S.A." will screw things up. (There probably is no right answer.) ...

splitting strings in postgres

I have a string with some spaces in it, and would like to split on the last space, and return the part of the string before that space. Does Postgres support this? I have not been able to solve this with the usual split_part-type functions. Example : "fort worth tx" -> "fort worth" ...