string-manipulation

SQL Server: How to trim all columns in a table

I have over 30 columns in my table (sql server 2008). Columns type are varchar(x). I know that in every column there is two extra spaces at the end of column value. How to use rtrim function for all columns and save this modification into this existing table? Edit: is there a way to do it using stored procedure or cursor where I don't h...

SQL Server 2008: How to find trailing spaces

How can I find all column values in a column which have trailing spaces? For leading spaces it would simply be select col from table where substring(col,1,1) = ' '; ...

Java add leading zeros to a number....

I need to return a string in the form xxx-xxxx where xxx is a number and xxxx is another number, however when i have leading zeros they disappear. I'm trying number formatter, but it's not working. public String toString(){ NumberFormat nf3 = new DecimalFormat("#000"); NumberFormat nf4 = new DecimalFormat("#0000"); ...

I need a REGEXP in php to search and replace "??" in dates.

I have data with dates written as 1992.09.02, as an example. If the dates are not available, you end up with 1992.09.?? or 1992.??.?? or otherwise .??.??.?? if no date is known. I need to change the ".??" to "" ie., nothing. Here's is my attempt, but I'm not getting anywhere. $text="^[1-9]. [\.\?\?] "; str_replace("\.\?\?", " ", "...

How do you pass strings in C Sharp?

How do you pass strings in C Sharp? How do you pass string variables as arguments to a method/procedure/function in a program written in C#? ...

How do I convert CamelCase into human-readable names in Java?

I'd like to write a method that converts CamelCase into a human-readable name. Here's the test case: public void testSplitCamelCase() { assertEquals("lowercase", splitCamelCase("lowercase")); assertEquals("Class", splitCamelCase("Class")); assertEquals("My Class", splitCamelCase("MyClass")); assertEquals("HTML", splitCa...

Split a HTML string into two strings without slicing through a word and preserving HTML in PHP

I'm looking for a way to split a string containing HTML in to two halves. Requirements: Split a string by a number of chars Must not split in the middle of a word Must not include HTML chars when calculating where to split the string For example take the following string: <p>This is a test string that contains <strong>HTML</strong> ...

keep HTMLformat after replace some text (using PHP and JS)

I would like modify HTML like I am <b>Sadi, novice</b> programmer. to I am <b>Sadi, learner</b> programmer. To do it I will search using a string "novice programmer". How can I do it please? Any idea? It search using more than one word "novice programmer". It could be a whole sentence. The extra white space (e.g. new line, tab) sh...

String replacement problem.

I want to provide some template for a code generator I am developing. A typical pattern for class is : public ${class_type} ${class_name} extends ${super_class} implements ${interfaces} { ${class_body} } Problem is if super_class is blank or interfaces. I replace extends ${super_class} with empty string. But I get extra spaces. So a...

Need to format character precedence in Strings.

I'm currently writing a Roman Numeral Converter for the fun of it. The problem works up to the aforementioned character precedence. Since Roman Numerals are not positional, i.e. III does not symbolize 1*whatever base^2 + 1*whatever base^1 + 1*whatever base^0. That of course makes it hard when somebody types in XIV and I need to make su...

What's the fastest way to convert a string of text into a url-safe variable?

I'd like to convert a string of text, e.g., "User Name" into something which I can turn into part of a url, e.g., "User-Name." What's the fastest way to do a string replacement ("-" for " ") as well as make sure that characters are only [a-zA-Z0-9]? ...

Obj-C combining strings

this must be such a simple problem but can someone tell me why this doesnt work: visibilityString1 = @"the"; visibilityString2 = @"end"; visibilityString = (@"This is %@ %@", visibilityString1, visibilityString2); Every time I try to combine strings this way, it will only return the second string so what I get is: end ...

Efficiently check string for one of several hundred possible suffixes

I need to write a C/C++ function that would quickly check if string ends with one of ~1000 predefined suffixes. Specifically the string is a hostname and I need to check if it belongs to one of several hundred predefined second-level domains. This function will be called a lot so it needs to be written as efficiently as possible. Bitwis...

Not-quite-JSON string deserialization in Python

I get the following text as a string from an XML-based REST API 'd':4 'ca':5 'sen':1 'diann':2,6,8 'feinstein':3,7,9 that I'm looking to deserialize into a pretty little Python dictionary: { 'd': [4], 'ca': [5], 'sen': [1], 'diann': [2, 6, 8], 'feinstein': [3, 7, 9] } I'm hoping to avoid using regular expression...

how to retrieve part of a string in java?

Hello everyone, I am designing a chat applet. In this, a user will append his name to the beginning of the message that he sends to the other user. In the window of other user, I want to retrieve the appended user name from that string. How do I do that? The message sent by the user is as follows : final_msg = user_name + ": " + user_m...

C# string.Split() Matching Both Slashes?

I've got a .NET 3.5 web application written in C# doing some URL rewriting that includes a file path, and I'm running into a problem. When I call string.Split('/') it matches both '/' and '\' characters. Is that... supposed to happen? I assumed that it would notice that the ASCII values were different and skip it, but it appears that I'm...

Delphi: Any StringReplaceW or WideStringReplace functions out there?

Are there any wide-string manipulation implementations out there? function WideUpperCase(const S: WideString): WideString; function WidePos(Substr: WideString; S: WideString): Integer; function StringReplaceW(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString; etc ...

How to detect if certain characters are at the end of an NSString?

Let's assume I can have the following strings: "hey @john..." "@john, hello" "@john(hello)" I am tokenizing the string to get every word separated by a space: [myString componentsSeparatedByString:@" "]; My array of tokens now contain: @john... @john, @john(hello) I am checking for punctation marks as follows: NSRange textRange...

Remove All After Delimiter PHP

Hi, I'm just wondering how I could remove everything after a certain substring in PHP ex: Posted On April 6th By Some Dude I'd like to have it so that it removes all the text including, and after, the sub string "By" Thanks ...

How can we extract substring of the string by position and separator.

How can we divide the substring from the string Like I have string String mainString="///Trade Time///Trade Number///Amount Rs.///"; Now I have other string String subString="Amount" Then I want to extract the substring Amount Rs. with the help of second string named subString not by any other method But it should be extracted ...