string

How to remove all integer values from a list in python

I am just a beginner in python and I want to know is it possible to remove all the integer values from a list? For example the document goes like ['1','introduction','to','molecular','8','the','learning','module','5'] After the removal I want the document to look like: ['introduction','to','molecular','the','learning','module'] ...

How can I organize two lists? string

I have two long lists. One is names....John, Paul, Gorge, and Ringo ect x 50,000 each guy has a number. The numbers are after all the names in order. SO its like 45, 32, 22, 65. 32 is Pual. 45 is John ect. How can i format this so that each name goes with the number. Thanks string ...

PHP - temporary variable

Hi I have a function that retrieves some data from the database, formats it as html and then stores this html into a variable, $output. The problem is that $output cannot be echoed on the screen now, only later, after other functions run. Also this data must be retrieved at this stage, not later. so how can I call this $output variable...

Sort C++ Strings with multiple criteria

I need to sort a C++ std::vector<std::string> fileNames. The fileNames are labeled as such YYDDDTTTT_Z_SITE YY = Year (i.e 2009 = 09, 2010 = 10) DDD = Day of the year (i.e 1 January = 001, 31 December = 365) TTTT = Time of the day (i.e midnight = 0000, noon = 1200) ZONE = Will be either E or W SITE = Four letter site n...

Split/tokenize/scan a string being aware of quotation marks

Is there a default/easy way in Java for split strings, but taking care of quotation marks or other symbols? For example, given this text: There's "a man" that live next door 'in my neighborhood', "and he gets me down..." Obtain: There's a man that live next door in my neighborhood and he gets me down ...

string or list substitution in Python

hi all... how would I go about taking a string ("h1", "h2", "h3, "h4") And substituting these values with numbers 1, 2, 3, 4? Correspondingly, how I would I preform the same operation but on a list instead? Thanks in advance... ...

This is illegal right?

For a personal project I have been implementing my own libstdc++. Bit by bit, I've been making some nice progress. Usually, I will use examples from http://www.cplusplus.com/reference/ for some basic test cases to make sure that I have the obvious functionality working as expected. Today I ran into an issue with std::basic_string::repla...

PHP - cut a string after X characters

What's the fastest way to trim a string to a specific number of characters, and append '...' if needed? ...

Outputting a Unicode character in C#

I'm new to programming and self taught. I'm trying to output the astrological symbol for Taurus, which is supposed to be U+2649 in Unicode. Here is the code I'm using... string myString = "\u2649"; byte[] unicode = System.Text.Encoding.Unicode.GetBytes(myString); Console.WriteLine(unicode.Length); The result I'm getting is the numbe...

In .NET converting a string with \n (new line) and other special characters to HTML and respecting the formatting?

in .NET, is there a way to convert a string with \n (new line) and other special characters to HTML respecting the formatting? If not I could write my own method to replace \n with < BR/>' put I wonder if there is a better way. ...

converting csv string to a string with spaces instead of commas in php

I'm having a string which is comma seperated like this $str = "john, alice, mary,joy"; Some are having space after comma and some don't. What I want to do is remove all the commas and make them like this: $str = "john alic mary joy"; What is the best way to do this in php? ...

regex for sepcifying empty string in java

i dont know how to generate a regex that can represent empty string in java ...

Can ( s is "" ) and ( s == "" ) ever give different results in Python 2.6.2?

As any Python programmer knows, you should use == instead of is to compare two strings for equality. However, are there actually any cases where ( s is "" ) and ( s == "" ) will give different results in Python 2.6.2? I recently came across code that used ( s is "" ) in code review, and while pointing out that this was incorrect I wante...

Use a random string as id in Ruby on Rails?

I want to create a web app similar to http://www.pastebin.com/ in Ruby on Rails. pastebin.com uses a random string to identify an item. Ruby on Rails uses an auto-incrementing number. How can I make Ruby on Rails also use these random strings as IDs for items, instead of auto-incrementing numbers? Thanks ...

Ruby string strip defined characters

in Python, we can e.g. "[foo ]".strip(" []") # -> "foo" how do we do this in Ruby? string strip method is stripping only whitespace .. UPDATE stripping is not deleting! : ) "[ foo boo ]".strip(" []") # -> "foo boo" ...

XSLT: Define a param with & ampersand

Hi, I need to define a xsl:param with a string that contains & character for further processing. For example: <xsl:param name="greeting" as="xs:string">Hi & Bye</xsl:param> Important Notice: I am using a xslt converter component in a webservice tool. What I do, is that I just initialize the param and as the webservice is called the...

String to Integer not working

Humm... I can do this easily in Java (and all other languages) but, it doesn't seem to work in Android. I simply want to get an integer number input from the user, press a button and do some simple math on it, then display it. I'm using a TextEdit (also tried a TextView) and have tried many different approaches but, none work. The cod...

Ruby: Insert spaces every X number of characters

In a ruby string, how can I insert a space every X number of characters? As an example, I'd like to insert a space every 8 characters of a given string. ...

Python fast string parsing, manipulation

I am using python to parse the incoming comma separated string. I want to do some calculation afterwards on the data. The length of the string is: 800 characters with 120 comma separated fields. There such 1.2 million strings to process. for v in item.values(): l.extend(get_fields(v.split(','))) #process l get_fields use...

MySQL string split

I uploaded a csv file to MySQL DB but for some reason data from two columns got glued to one. e.g. the data 0880174V,D should have gone to two different columns. Is there a way (via sql) i can split the data from this column (i.e. as 0880174V and D) and update the table, without having to delete the record and re-upload? I have a milli...