string-manipulation

String functions in SQL

I need query (to be more specific, it is view, not query) that will return string column. String will be code, that might be prefixed with two letters (LJ). If it is prefixed -- prefix have to be trimmed. If there is no prefix present, it should be left untouched. Is it possible to do such thing in SQL? Server is FirebirdSQL 1.5. Non...

Need regular expression for this string

Hello, I am writing a small program to do some calculations. Basically the input is the following: -91 10 -4 5 The digits can have the negative sign or not. They are also separated by a space. I need a regular expression to filter each digit including the sign if there is one. Thanks! Adam ...

Appending string to UILabel text?

Hi, I'm starting to develop for the iPhone. I have a beginner-type question, I'm sure: I have this, which works: testLabel.text = [NSString stringWithFormat:@"%@ to %@", testLabel.text, newLabelText]; I wish I could use the "+=" operator, but I get a compile error (Invalid operands to binary +, have 'struct NSString *' and 'struct NS...

C - Concatenate all the heads of a string

Hey fellas... OK, a recent quiz entry tasked the student with writing a method 'longhead' (char *longhead) that would return a string consisting of the concatenation of all of the heads in a given string. Example: char *string = "this"; printf("%s\n", longhead(string)); OUTPUT: tththithis I did come up with a solution, but it works ...

String manipulation in Python docstrings

I've been trying to do the following: #[...] def __history_dependent_simulate(self, node, iterations=1, *args, **kwargs): """ For history-dependent simulations only: """ + self.simulate.__doc___ What I tried to accomplish here is to have the same documentation for this p...

Need help with Windows Speech Recognition script to compound a string

The command below for Windows Speech Recognition forces the speech recognition engine to use literal text (""all seventy six people paid five dollars") instead of the default ("all 76 people paid $5"). I'm trying to adapt this command to remove the spaces between words so that I could program using speech by saying things like: "Securi...

Smalltalk, how to insert tab in a string

How do you insert a "tab" in a string? I thought it was t enclosed in <> , but I do: 'Name <t> Age <t> Occupation' prints exactly how it's typed. I would like to get Name Age Occupation instead of Name <t> Age <t> Occupation ...

string[] management help (C#))

ok, so ill cut to the chase here. and to be clear, im looking for code examples where possible. so, i have a normal string, lets say, string mystring = "this is my string i want to use"; ok, now that i have my string, i split it by the space with string[] splitArray = mystring.Split(new char[] { ' ' }); ok, so now i have splitAr...

Setting NSMutableString Element To Number

Ola Folks, I want to populate an NSMutableString at runtime by both assigning a specific number (0-255) to an element and appendFormat to add to the string. If this were an unsigned char array, I could just directly assign the number using: UnsignedCharRay[SomeIndex] = 5; For reasons I think I understand but do not like, NSMutable...

How to get date from this string - regex?

Hi, I have this string: \tid [email protected]; Tue, 6 Oct 2009 15:38:16 +0100 and I want to extract the date (emboldened) to a more usable format, e.g. 06-10-2009 15:38:16 What would be the best way to go about this? thanks in advance leddy ...

std::string equivalent for data with NULL characters?

I'd like to read a binary file and use something like std::string that automatically resizes the buffer and such. I'm using Visual C++. What are my options? ...

String concatenation is extremly slow when input is large

Things like the code below is super slow: var str:String = "" for (var i:Number = 0 ; i<1000000000000000000 ; ++i) { str += "someLongLongLongLongLongLongLongLongLongString"; } There is StringBuilder in Java but seems there is no equivalent for AS. So, how do you guys handle large strings concatenation? Update: Thanks for every...

Comparing sentences (strings) in AS3

Hello, I'm building a short quiz where the user needs to input the meaning of an acronym. This means I need to compare a long string (usually a sentence) typed in by the user with an acronym. I have a feeling I'm not doing it right. For my testing I'm copy-pasting the correct answer to make sure the spelling is correct however I keep get...

Java: StringBuilder, static method and possible synchronization issues

Is it possible for code like this to be not thread safe? It is a static method and we are using an local instance of stringbuilder. I guess the input strings might be held by other objects? public static String cat(final String ... strings) { ... ... final StringBuilder sb = new StringBuilder(totLength); for (int i = ...

Remove whitespace and line breaks between HTML elements using jQuery

Using jQuery, I'd like to remove the whitespace and line breaks between HTML tags. var widgetHTML = ' <div id="widget"> <h2>Widget</h2><p>Hi.</p> </div>'; Should be: alert(widgetHTML); // <div id="widget"><h2>Widget</h2><p>Hi.</p></div> I think the pattern I will need is: >[\s]*< Can this be accomplished without...

How can I build a string from a collection with Linq?

I'm building flat file content from collections of strings. Example collection: A, B, C, D, E, etc. I want to be able to output these values to a string with line feeds in one swoop with Linq if possible. Sample Output: A B C D E etc. Here's the VB.NET code that does the job currently: For Each fieldValue As String In field.Va...

How can I name Tuples?

Is there a language agnostic algorithm to name tuples? Specifically, I want the following function: 1 => Single 2 => Double 3 => Triple 4 => Quadruple ... 10 => Decuple ... 100 => Centuple First of all, is this human-language independent? For example, will that be understood in Spain and Russia? Secondly, what is t...

C++ stringstream returning extra character?

I've been attempting to use the C++ stringstream class to do some relatively simple string manipulations, but I'm having a problem with the get() method. For some reason whenever I extract the output character by character it appends a second copy of the final letter. #include <iostream> #include <sstream> #include <string> using namesp...

Easiest way to split a string on newlines in .net?

I need to split a string into newlines in .NET and the only way i know of to split strings is with the Split method. However that will not allow me to (easily) split on a newline, so what is the best way to do it? ...

how to limit my mysql select characters

I am grabbing info from three rows in my table, and echoing one of them in a anchor tag. How can I limit the amount of characters on the $title variable that are shown in the anchor tag. Code: $results = mysql_query("SELECT * FROM news "); while($row = mysql_fetch_array($results)) { $id = $row['id']; $title = $row['title'];...