string

random.sample return only characters instead of strings

Hi SO, This is a kind of newbie question, but I couldn't find a solution. I read a list of strings from a file, and try to get a random, 5 element sample with random.sample, but the resultung list only contains characters. Why is that? How can I get a random sample list of strings? This is what I do: names = random.sample( open('n...

Delphi - structures' strings not being freed [FastMM manager]

If I declare PSomeStruct = ^TSomeStruct; TSomeStruct = record s1 : string; end; and I run the following code: var p: PSomeStruct; begin new(p); p^.s1:= 'something bla bla bla'; dispose(p); the FastMM 4 memory manager reports that there was a memory leak (type: string, data dump: "something bla bla bla"). However, if I ...

how to manipulate strings with shell-script

This is what I used: for i in `find some -type f -name *.class` I got: some/folder/subOne/fileOne.class some/folder/subOne/fileTwo.class some/other/sub/file.class next, I would like to get rid of the "some/" for each value of $i. What command can I use? Do I HAVE to save them into a file first? Thanks ...

[objective c] getting string in NSMutableArray : Why it doesn't work?

I have the error -[NSCFString stringValue]: unrecognized selector sent to instance 0x1578c when executing this code I don't understand what I'm doing wrong name is a NSString self.searchValues= [[NSMutableArray alloc] init]; name=@"Bob"; if(self.name!=nil) [searchValues addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys:@"N...

can i do $bar = "My name is $bar"; in asp.net with C#?

i now have experience working on both asp.net and php. asp scores on the integration and rich set of outofbox features and the power of C#. However after using php for some time, i came across a nifty feature in it which i desire to be there in asp.net in php we can use the variables like this $bar = "My name is $bar and my pet's name...

C Convert String to Ints Issue

I'm trying to parse some input on an embedded system. I'm expecting something like this: SET VARNAME=1,2,3,4,5,6,7,8,9,10\0 When I'm converting the separate strings to ints, both atoi() and strtol() seem to be returning 0 if the string begins with 8. Here is my code: char *pch, *name, *vars; signed long value[256]; int i; #ifdef UA...

Most optimal way to parse querystring within a string in C#

I have a querystring alike value set in a plain string. I started to split string to get value out but I started to wonder that I can proabably write this in one line instead. Could you please advice if there is more optimal way to do this? I am trying to read "123" and "abc" like in Request.QueryString but from normal string. protect...

Convert Unicode to String in Python (containing extra symbols)

How to you convert a Unicode string (containing extra characters like £ $, etc) into a python string? ...

Parsing string in Ruby

I have a pretty simple string I want to parse in ruby and trying to find the most elegant solution. The string is of format /xyz/mov/exdaf/daeed.mov?arg1=blabla&arg2=3bla3bla What I would like to have is : string1: /xyz/mov/exdaf/daeed.mov string2: arg1=blabla&arg2=3bla3bla so basically tokenise on ? but can't find a good example. ...

What is the difference between VBScript's + and & operator?

On every site that talks about VBScript, the '&' operator is listed as the string concatenation operator. However, in some code that I have recently inherited, I see the '+' operator being used and I am not seeing any errors as a result of this. Is this an accepted alternative? ...

get sub string in shell script

if I have a string like some/unknown/amount/of/sub/folder/file.txt how can I get only the the file.txt sub string, remove the front part, while the length is unknown. thank you EDIT: file name could be any length, and sub folders could be any levels. ...

iPhone Dev - NSString Creation

I'm really confused with NSStrings. Like when should I do NSString *aString = @"Hello"; of should it be: NSString *aString = [[NSString alloc] initWithString:@"Hello"]; But then its different when you're assigning a value to an NSString property isn't it? Can someone clear this up for me? Thanks!! ...

How can I accept strings like "$1,250.00" and convert it to a decimal in C#?

How can I accept strings like "$1,250.00" and convert it to a decimal in C#? Do I just do a replace("$", "") and (",", "") or is there a different way I should handle this kind of input? ...

Lesser known string similarity metrics

Hello. This may be a hard question to answer but I'm researching something and I was wondering if anyone knew of "lesser known" string similarity metrics (see this page for examples of well-known ones). I've been to wikipedia and Sourceforge has a nice library called Simmetrics with a bunch of string metric algorithms. Has anyone done so...

Split string on multi-char seperator and maintain seperator

Using VB.NET - I have a string: "##RES00012##Some value ##RES00034##Another value" That I want to split using the "##RES" as a seperator to: "##RES00012## Some value " and "##RES00034## Another value" The string.split function doesn't seem to offer an overload to split on multiple characters or array of characters and maintain the se...

UTF8 encoded text cones in a TDesC8 variable from Xml-parser in Symbian

Hi! I'm using Carbide.c++ 2.0 to create a S60 application that consumes my own webservice. I've used the Yahoo! Image Search example as a starting point and data is shipped back and forth nicely. Problems occur when there are non-english characters in the reply so the text presented to the user in the listbox is incorrect. The XML-docume...

How do I extract lines between two line delimiters in Perl?

I have an ASCII log file with some content I would like to extract. I've never taken time to learn Perl properly, but I figure this is a good tool for this task. The file is structured like this: ... ... some garbage ... ... garbage START what i want is on different lines END ... ... more garbage ... next one START more stuff I...

regexp to match string1 unless preceded by string2

Using Ruby, how can I use a single regex to match all occurrences of 'y' in "xy y ay xy +y" that are NOT preceded by x (y, ay, +y)? /[^x]y/ matches the preceding character too, so I need an alternative... ...

Use a String as an E4X Expression in AS3?

I need to use a string to access nodes and attributes in XML using E4X. It would be ideal to have this scenario (with XML already loaded): var myXML:XML = e.target.data; var myStr:String = "appContent.bodyText.(@name == 'My Text')"; myXML.myStr = "New Value for bodyText node where attribute('name') is equal to 'My Text'"; I ultimate...

Python string templater

I'm using this REST web service, which returns various templated strings as urls, for example: "http://api.app.com/{foo}" In Ruby, I can then use url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar') to get "http://api.app.com/bar" Is there any way to do this in Python? I know about %() templates, b...