string-manipulation

How to format a String onto one line, StringUtils?

Hi, I have a String that I'm passing to log4j to have it logged to a file, the contents of that string is XML, and it is formatted to be on multiple lines with indentations and so forth, to make it easy to read. However, I would like that XML to be all on one line, how can I do this? I've had a look at StringUtils, I guess I could stri...

Instring Function in R

Hi all, Close to finishing up my first project entirely in R, but I am stuck. I don't really have a good grasp of regex, but usually can accomplish my tasks with substring, instring, len, or comparable functions. I have two questions. Where can I find a list of string functions in R, and 2nd, does R have an instring type function? ...

Chained string formatting in Python

In handling a little SQL formatting I was amazed to find I could chain string formatters: def get_sql(table, limit=True): sql = "select report_date from %s" if limit: result = "%s limit 1" % sql % table else: result = sql % table return result Is this legit? Any reason not to do this? ...

Trying to remove "»" with php

I'm trying to remove this character, and this character only from a $string with php. I've tried str_replace("»","",$test) and str_replace(chr(187),"",$test) but they can't touch it. The issue is it isn't in the same spot every time, so I can't even get creative with trimming the ends Any help? ...

strcat problem with char *a[10]

hey, here's my code #include <stdio.h> #include <string.h> int main() { char *array[10]={}; char* token; token = "testing"; array[0] = "again"; strcat(array[0], token); } why it returns Segmentation fault? I'm a little confused. ...

Which PHP String function to use?

Which string function can I use to strip everything after - ? The string is not predefined so rtrim() does not work. 9453-abcafaf3ceb895d7b1636ad24c37cb9f-100.png?1 ...

C#: most readable string concatenation. best practice

Possible Duplicate: How should I concatenate strings? There are several ways to concat strings in everyday tasks when performance is not important. result = a + ":" + b result = string.Concat(a, ":", c) result = string.Format("{0}:{1}", a, b); StringBuilder approach ... ? what do you prefer and why if efficiency doesn't ma...

Select a specific character in a string and offset it (visually) with Jquery

Hi I'm trying to use Jquery/Javascript to mimic a broken typewriter font (since I could not find one). But I want to make it random which letter gets broken. I was able to split the string of the id that I wanted and use a bit of code I found to get a random number between 0 and the total length of the string. What I'm having proble...

Using String or StringBuffer in Java: which is better?

Hello I read a lot about using StringBuffer and String especially where concatenation is concerned in Java and whether one is thread safe or not. So, in various Java methods, which should be used? For example, in a PreparedStatement, should query be a StringBuffer: String query = ("SELECT * " + "FROM User " +...

Looking for a PHP's str_split() replacement

Let's say I have this little piece of code: <?php $tmp = str_split('hello world!',2); // $tmp will now be: array('he','ll','o ','wo','rl','d!'); foreach($tmp AS &$a) { // some processing } unset($tmp); ?> How can I do this in Python v2.7? I thought this would do it: the_string = 'hello world!' tmp = the_string.split('',2) for a...

java macroresolver.

Hello I am a newbiew to java. I am trying to write an macroresolver I have string which is represneted as String s = '{object.attribute}' --> result of the resolver should be 'attribute' String prefix = '{object.' String suffix = '}' that was easy. i also want to extend to use the same resolver to resolve the following String s ...

DB2 Implied Decimal

Running DB2 8.2 Fixpak 18 for LUW, I need to convert a DECIMAL field to a IMPLIEDDECIMAL for a file export. I cannot find anything in the documentation online, please help. ...

Converting an empty string to a date, and then back.

I'm trying to do some validation testing in VB.NET. If Entity.WeekEndDate.ToString = String.Empty Then ErrorList.Add(New cValidationError("id", "Incorrect Week End Date")) Where WeekEndDate is of type Date. When I originally build the object, how can I insert a value into WeekEndDate that will generate an empty string(ie....

How to replace letters in a string with underscores?

Say I got a random word like WORD, i want to replace each of the letters of the word with _. How can I do it? Also, say if there is a space between the word like WO RD, I don't want it to replace the space with _. ...

uppercase random number of characters from a random alphanumeric string

I have some random string with unknown content, what is known is that the content is alphanumeric and in lower case. I am looking for a simple method to upper case a random number of the alpha characters in that string. The higher the randomness the better. I can think of a few ways to do this, but none of them seem very optimal. alri...

Detecting if an NSString contains...?

How can I detect if a string contains a certain word? For example, I have a string below which reads: @"Here is my string." I'd like to know if I can detect a word in the string, such as, "is" for example. THank you in advance ...

Calculating the disk space a string would take up without saving it to disk

I'm writing an app where I want to compare two strings' size. By size, I mean the disk space they would take up if they were directly saved to the disk. Is it possible to calculate the size of a string in C# without saving it to disk and checking the file information (unless it is more efficient to save it to disk)? ...

Insert array contents into a string

Hello, I am trying to insert the contents of an array in to a string using PHP. My array ($array1) looks like this: Array1 ( [0] => http://www.example.com/1 [1] => http://www.example.com/2 ) I want to insert both links in to a coma separated string, so I can then insert it in to a database field. I tr...

php mb_convert_case() keep words that are in uppercase

Hi, Assuming I have a string "HET1200 text string" and I need it to change to "HET1200 Text String". Encoding would be UTF-8. How can I do that? Currently, I use mb_convert_case($string, MB_CASE_TITLE, "UTF-8"); but that changes "HET1200" to "Het1200. I could specify an exception, but it won't be an exhaustive. So I rather all upperca...

"average length of the sequences in a fasta file": Can you improve this Erlang code ?

I'm trying to get the mean length of fasta sequences using Erlang. A fasta file looks like this >title1 ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCGATCATATA ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCTCGTACGC >title2 ATCGATCGCATCGATGCTACGATCTCGTACGC ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATC...