string

Unpacking 3-byte/24-bit data chunks with Ruby

I am building a pure-Ruby WAV file read/write library, learning deeper Ruby functionality as I go. It currently works well with 16-bit audio, as I am able to use String.unpack('s*') to pull individual audio samples out into an array of signed integers. I am having trouble wrapping my mind around how to go about dealing with 24-bit audio,...

Adding a string in front of a string for each item in a list in python

I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. n is my list of websites h is "http" for p in n: if p[0]!="h": p= h+ p else: continue return n when i return the list, it returns my original...

See if a ruby string has whitespace in it

I want to see if a string has any white space in it. What's the most effective way of doing this in ruby? Thanks ...

How to cast array elements to strings in PHP?

If I have a array with objects: $a = array($objA, $objB); (each object has a __toString()-method) How can I cast all array elements to string so that array $a contains no more objects but their string representation? Is there a one-liner or do I have to manually loop through the array? ...

Externalizing Strings n XML files

Is there any way to externalize a string that is inside of a xml file? ...

Adding NSMutableString to NSArray

I'm having some trouble adding a mutable string (that has been changed with replaceOccurrencesOfString) to an array. This is related to another question I asked: http://stackoverflow.com/questions/2124860/remove-double-quotes-from-nsstring Here is the code //original String NSString *aString = @"\"Hello World\""; NSLog(@"Original Stri...

Basic Regexp Question: How to modify only the lines starting with a STRING with sed

I have to replace all ocurrences of: 5.6xx and 5.5xx (where x is a 0-9 digit) on a textfile with 5.500, but only when the line that contains the match starts with a string (e.g. STARTSTRING). That means STARTSTRING 5.610 4.500 3.550 5.530 OTHERSTRING 5.600 5.500 5.500 5.600 should become STARTSTRING 5.500 4.500 3.550 5.500 OTHERSTRIN...

Remove all lines between two strings

In a sh shell script. Given data in a text file: string1 string2 gibberish gibberish string3 gibberish string4 How could you use awk or sed to remove all lines between string2(inclusive) and string3(not including string 3)? to end up with: string1 string3 string4 ...

How do I print a non-null-terminated string using printf?

How can I print a non-null-terminated string using printf, assuming that I know the length of the string at runtime? ...

ANSI C, integer to string without variadic functions

I'm currently working with a SPC that supports ANSI C, but uses its own flavour of the GNU compiler, which doesn't compile any variadic functions and things like itoa. So using sprintf & co. isn't an option for converting integers to strings. Can anyone guide me to a site where a robust, sprintf- free implementation of itoa is listed or ...

Constraining string length in domain classes

Hi all, I have a persistence ignorant domain model that uses abstract repositories to load domain objects. The concrete implementation of my repositories (the data access layer (DAL)) uses entity framework to fetch data from a sql server database. The database has length constraints on a lot of its varchar columns. Now imagine that I ...

Read key/value pairs in HttpWebResponse

Hi there, I want to read a string that looks exactly like this: VPSProtocol=2.22 Status=OK StatusDetail=0000 : The Authorisation was Successful. VPSTxId={BBF09A43-913E-14E3-B41B-E5464B6FF8A9} SecurityKey=EH8VFZUSH9 TxAuthNo=4979698 AVSCV2=SECURITY CODE MATCH ONLY AddressResult=NOTMATCHED PostCodeResult=NOTMATCHED CV2Result=MATCHED CAVV...

Javascript equalsIgnoreCase: case insensitive string comparation

How do I perform case insensitive string comparison in Javascript. ...

Adressing part of a string via the array syntax in Python

Is it, in Python, possible to adress a specific character in a string by the standard array syntax? Example, PHP: $foo = 'bar'; echo $foo[1]; // Output: a It didn't work like in PHP so I wanted to know if it is possible using some other way ...

Delphi - Compare and Mark String Differences

What I need to do is compare two strings and mark the differences with begining/ending marks for changes. Example: this is string number one. this string is string number two. output would be this [is|string is] string number [one|two]. I've been trying to figure this out for some time now. And I found something I blieved would h...

Storing multiple values in a single cell in MySQL

I'm storing multiple numbers in a MySQL cell by using a delimiter (eg "1,5,10") and the TEXT datatype. How do I perform lookups like this? SELECT * FROM MyTable WHERE MultiVals CONTAINS "5" And lastly, is this the preferred approach to store such values? I'm using this like a linker table, to link certain rows to multiple other rows ...

How to tell if a html string will show as empty in the browser? (C# / regex?)

Hi, I have a control that will return some html to me as a string. Before putting that on screen, I'd like to be able to tell if it'll just show as empty. For example the control might return <p><br /></p>, which when I test using C# for string.Emtpy obviously it's not - but nothing gets displayed on screen. Is there a regex function ...

Troubles with Unicode string encoding in Android

I get strings in different encodings (ID3 tags). I use e.g. new String( bytes, "UTF-16LE" ) to decode them. On my device (Motorola Milestone) and in the emulator, this works fine. But some users complained they get results like "T i t l e n a m e". I've tried the Sun codepage names instead (e.g. "UnicodeBigUnmarked"), with the same res...

Why does appending "" to a String save memory?

I used a variable with a lot of data in it, say String data. I wanted to use a small part of this string in the following way: this.smallpart = data.substring(12,18); After some hours of debugging (with a memory visualizer) I found out that the objects field smallpart remembered all the data from data, although it only contained the s...

Does this code depend on string interning to work?

I'm creating a key for a dictionary which is a structure of two strings. When I test this method in a console app, it works, but I'm not sure if the only reason it works is because the strings are being interned and therefore have the same references. Foo foo1 = new Foo(); Foo foo2 = new Foo(); foo1.Key1 = "abc"; foo2.Key1 = "abc"; foo1...