string-manipulation

Replace substring with a regex combination

Since I'm not that familiar with java, I don't know if there's a library somewhere that can do this thing. If not, does anybody have any ideas how can this be accomplished? For instance I have a string "foo" and I want to change the letter f with "f" and "a" so that the function returns a list of strings with values "foo" and "aoo". Ho...

Compare strings on iPhone fails?

Hi, I'm trying to compare two strings with each other on the iphone, but the IF statement is always false. Here's my code: NSLog([[UIDevice currentDevice]uniqueIdentifier]); if ([[[UIDevice currentDevice]uniqueIdentifier] compare:[[NSUserDefaults standardUserDefaults] valueForKey:@"id"]] == NSOrderedSame) { //OK NSLog("Do stuff...

What's the best way to modify StringTokenizer output for only English words that would be needed in a full text search?

To add full text search to my App Engine app I've added the following field to my model: private List<String> fullText; To test the search, I took the following text: Oxandrolone is a synthetic anabolic steroid derived from dihydrotestosterone by substituting 2nd carbon atom for oxygen (O). It is widely known for its exceptionally s...

Linq's Aggregate Function, How to make a CSV String

I'd like to make a comma seperated value string with Linq's Aggregate function. Anyone know how to do this? Given an array of strings like this: var authors = new string[] {"author 1", "author 2", "author 3"}; How do I get a single string like this author 1, author 2, author 3? I'm thinking something like authors.Aggregate(author => ...

Replacing some part of string with Python

I have a SQL string, for example SELECT * FROM benchmark WHERE xversion = 1.0 And actually, xversion is aliased variable, and self.alias has all the alias info something like {'CompilationParameters_Family': 'chip_name', 'xversion': 'CompilationParameters_XilinxVersion', 'opt_param': .... 'chip_name': 'CompilationParameters_...

How to echo out all elements of php array at once ?

hi friends I have a php array for eg. $mob_numbers= array(12345674, 12345675, 12345676,12345677); I want to eacho out all of them at once so that it appears 12345674,12345675,12345676,12345677 (with comma) . How do i do it ? I tried array explode, didn't work. Pls help ...

How can I remove accelerator characters from a string?

I have a caption for a GUI control, and I want to convert it to a simple text string. Specifically, I want to remove the accelerator metacharacters. For example (examples assume WinForms): Strip off single occurrences of the metacharacter: &Yes becomes Yes Convert double occurrences to single: Income && Expense becomes Income & Expens...

How to return the first character of a variable in gmake

Using GNU's make, I'd like to extract the first character of a variable. Currently I'm using the shell function to have bash perform the substring. I'm wanting to know if there is a way using gmake's built-ins to do the same. DIR=/user/$(shell echo "$${USER:0:1}")/$(USER)/ ...

Insert a string into a string given an index

Hi, I know this is a really simple question, but I was just wondering if there is a native php method to inject a string into another string. My usual response to a new text manipulation is to consult the manual's listings of string functions. But I didn't see any native methods for explicitly inserting a string into another string so ...

C++ remove character from string

Hi! I am currently trying to implement deleting characters from a text field in C++. If the user hits Backspace, the following code is executed. There is currently no cursor, it should just remove the last character... if (mText.length() > 0){ mText.erase( mText.length() - 1, 1); // mText.resize(mText.length() - 1); } This wo...

How to compare percentages that are strings?

I have a string "+1.29%" or "-1.29%" How can I convert this into a float or double so I can compare the values? This is how my comparator class looks like: package org.stocktwits.helper; import java.util.Comparator; import org.stocktwits.model.Quote; public class PercentChangeComparator implements Comparator<Quote> { ...

PHP string concatenation problem?

function formatUpdate($tweet,$dt,$picture,$username) { if(is_string($dt)) $dt=strtotime($dt); $tweet=htmlspecialchars(stripslashes($tweet)); $at = "@" . $username; return' <li> <a href="nano.com/' . $username . '"><img class="avatar" src="images/' . $picture . '" width="48" height="48" alt="avatar" /></a...

Sort characters in strings with mysql?

I'm wondering how I can sort the characters in a string from a MySQL result. A function I could call on a string like 'letter', which would return the string 'eelrtt'. All characters would be sorted in alphabetical order. I couldn't find a function in the MySQL docs, am I missing something or is this something that needs to be done manu...

Find associated value to a keyword in file with python

Sorry for the beginner python question, but I cant find anywhere how to do this, so bear with me. I am trying to extract the values from a file containing keyword followed by a value: Example: length 95 width 332 length 1253 length 345 width 22 How do I extract all the values assosiated with the keyword "length" for example? ...

How to Escape Single Quotes in Python on Server to be used in Javascript on Client

>>> sample = "hello'world" >>> print sample hello'world >>> print sample.replace("'","\'") hello'world In my web app I need to store my python string with all single quotes escaped for manipulation later in the client browsers javascript. Trouble is python uses the same backslash escape notation so the replace operation as detailed ab...

PHP: Seperate one field in two.

As many recommend me to seperate firstname and lastname instead of "full_name" with everything in, how can i seperate them to each variables, so if you example type in the field: "Dude Jackson" then "dude" gets in $firstname and Jackson in the $lastname. ...

Accurate algorithm for normalizing taxonomy terms?

Hello, I'm developing a shopping comparison website, and the project is in a very advanced stage. We index 50 million products daily using merchant feeds from various affiliate networks. Most of the problems I had is already solved, including the majority of the performance bottlenecks. What is my problem: Please, first of all, we are ...

Is there a function to split a string in plsql?

I need to write a procedure to normalize a record that have multiple tokens concatenated by one char, I need to obtain these tokens splitting the string and insert each one as a new record in a table. Does Oracle have something like a "split" function? ...

How to Use String.Filter with Multi-Value Parameters

In the Expression builder window in SQL Server Reporting Services 2008 R2 under Common Functions -> Text -> Item, there is an expression called Filter. This appears to correspond with the Strings.Filter method in the .NET framework. The description of Filter is as follows: Returns a zero-based array containing a subset of a String arr...

How do I delete "filename.txt" in "blah\bleurgh\filename.txt" in VBS?

Hi, such a silly question I know, but I want to remove the filename in a string such as "blah\bleurgh\filename.txt" To delete the extension I would do strFile = Left(strFile, InStrRev(strFile, ".") - 1) But doing similiar to delete the filename at the end does nothing, e.g. tempStrFile = Left(tempStrFile, InStrRev(tempStrFile, "\...