string-manipulation

Matching delimited string to table rows

So I have two tables in this simplified example: People and Houses. People can own multiple houses, so I have a People.Houses field which is a string with comma delimeters (eg: "House1, House2, House4"). Houses can have multiple people in them, so I have a Houses.People field, which works the same way ("Sam, Samantha, Daren"). I want ...

How to parse in VBA a string that contains Mathematics special ASCII code and correct it

Hi ! I'm currently writing a code in VBA to retrieve prices for some financial models. The problem I have is in the excel spreadsheet where I have special Ascii characters like ⅞ ¼ etc... I would need using VBA to transform this in 7/8 1/4 etc... How could I do that ? Thanks for your help ...

Break up data from one column into multiple columns in a new table (MySQL)

I have a table full of data, where one column is full of different entries for each row, where the data is formatted like this: A:some text|B:some other text|C:some more text| I want to separate those strings of text into two columns on a new table. So the new table should have one column for A, B, C etc. and the other column will have t...

Fastest way to get the number in tail of a string

Given that we have this kind of string "XXXXXXX XXXXX 756", "XXXXX XXXXXX35665", (X is a character), which is the fasted way to get the number in the end of string? EDIT: well, this is just-for-fun question. Solve this is quite simple, but I want to know the fastest algorithm to archive this. Rock it on! ...

What would be faster in this context String.Format or String.Replace?

string str = 'my {0} long string {1} need formatting'; Should I be doing the following, str = string.Format(str, "really", "doesn't"); or creating a method like so and calling str = str.ReplaceWithValues("really", "doesn't"); public string ReplaceWithValues(this string str, params object[] values) { string ret = str; for (...

Replace & with & in C#

Ok I feel really stupid asking this. I see plenty of other questions that resemble my question, but none seem to be able to answer it. I am creating an xml file for a program that is very picky about syntax. Sadly I am making the XML file from scratch. Meaning, I am placing each line in individually (lots of file.WriteLine(String)). I ...

Change string order - Sql server

Hi All, I am moving data from an old table to a SQL server new version and am struggling with something that hopefully someone can help with. I have a column in the old table with 'EmployeeName' in the order firstname.lastname. In the new table we will be using a guid to identify the employees. The table with the guid's has the names ...

Trim only the first and last occurrence of a character in a string (PHP)

This is something I could hack together, but I wondered if anybody had a clean solution to my problem. Something that I throw together wont necessarily be very concise or speedy! I have a string like this ///hello/world///. I need to strip only the first and last slash, none of the others, so that I get a string like this //hello/world/...

PHP Replace Last Occurence of a String in a String?

Anyone know of a very fast way to replace the last occurrence of a string with another string in a string? ...

String Replace in PHP

I have string named File_Test_name_1285931677.xml. File is the common word and 1285931677 is a random number. I want to remove File_ and _1285931677.xml, i.e. prefix up to first _ and suffix from last _ on. ...

Get integer portion of string in Pascal

I have a string Alpha 2 from which I need to extract the integer portion i.e. 2. This is a quick and dirty project and I'm not currently interested in learning Pascal. All I need is a quick answer! ...

JavaScript equivalent of the MySQL function SUBSTRING_INDEX()

Hi, SUBSTRING_INDEX() in MySQL returns a substring from a string before the specified number of occurrences of the delimiter. Is there any equivalent function in JavaScript? I need to perform the same thing.. but on a string value in JavaScript. ...

How to downcase the first character of a string in Python ?

Hello, There is a function to capitalize a string, I would like to be able to change the first character of a string to be sure it will be lowercase. How can I do that in Python ? ...

String formatting in Java

I've been using python too much lately and I forget if there's a way to do this in Java: print "I am a %s" % string I googled, but it's hard to find simple stuff like this when you don't know exactly what this is called in each language. ...

Merge of two strings in Oracle SQL

Is there any way to merge two strings returned in a query like this: I have one string '<6 spaces>XYZ' and other string '<3 spaces>ABC<3 spaces>'. Basically each string is divided in 3 parts and two of any parts will be blank. I want to merge these two strings to produce the output: '<3 spaces> ABCXYZ'. Another example can be 'ABC<6 sp...

Creating a String from a Collection of Objects

I have a question. I have a class of Cars that I need to display in a simpli-ish string if they will be sold or not base on their number. So like this: Public Class Car Property Index As Integer Property Sell As Boolean End Class Public Class Cars Property Vehicles As New List(Of Car) From { {New Car Wit...

ASP.net c# replace string not working

// Build email link confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode; using (SqlCommand cmd = new SqlCommand("SELECT newRegEmailBody, newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)", Master.cn)) { SqlDataReader rdr = cmd.Exec...

what is for Python as 'explode' is for PHP

I had a string which is stored in a variable myvar="Rajasekar SP" . I want to split it with delimiter like we do using explode in PHP. But dont know the alternative for the explode in python. Please help ...

Determine if a string contains a base64 string inside of it

I'm trying to figure out a way to parse out a base64 string from with a larger string. I have the string "Hello <base64 content> World" and I want to be able to parse out the base64 content and convert it back to a string. "Hello Awesome World" Answers in C# preferred. Edit: Updated with a more real example. --abcdef \n Content-Type:...

Increment a number within a string (C#)

Hi - I have a string with a number at the end, after a dash ("-"). I'd like to create that same string with that number incremented by 1. Pretty simple, but I'm wondering if there's a better approach to this? Thanks! string oldString = "BA-0001-3"; int lastIndex = oldString.LastIndexOf("-"); string oldNumber = oldString.SubString(las...