string

Avoiding/Removing nil when using a case statement while parsing a string

sample data: DNA : This is a string BaseQuality : 4 4 4 4 4 4 6 7 7 7 Metadata : Is_read DNA : yet another string BaseQuality : 4 4 4 4 7 7 4 8 4 4 4 4 4 Metadata : Is_read SCF_File . . . I have a method that is using a case statement as follows to separate parts of a longer text file into records using the delimeter "\n\n"...

C++: How to build Strings / char*

Hi, I'm new to C++. I want to make a char*. But I don't know how. In Java is it just this: int player = 0; int cpu = 0; String s = "You: " + player + " CPU: " + cpu; How can I do this? I need a char*. Where I'm focusing on is to paste the integer after the string. Edit: I want to use a method that takes an argument char *, so if...

Array of strings in groovy

In ruby, there is a indiom to create a array of strings like this: names = %w( lucas Fred Mary ) Is there something like that in groovy? ...

Search for a string in Enum and return the Enum

I have an enumerator: public enum MyColours { Red, Green, Blue, Yellow, Fuchsia, Aqua, Orange } and i have a string: string colour = "Red"; I want to be able to return: MyColours.Red from: public MyColours GetColour(string colour) So far i have: public MyColours GetColours(string colour) { s...

Jquery, Convert Title to Slug

Hi Guys, I have a PHP script that does the following: It takes a string, for example, "This is a Great Blog Post, #1!", and returns the following string, "this-is-a-great-blog-post-1". I'm not exactly a Jquery expert, that's why I'm asking this question. Does someone know of a Jquery (or Javascript, for that matter) script that will d...

C# - What does "\0" equate to?

I am playing with Pex and one of the parameters it passes into my method is "\0". What does that mean? My guess is an empty string ("") based on the content of my method. However, if it is the same then why not just use "" instead of "\0"? Anyone know what it is? ...

Java finding substring

I have the following String: oauth_token=safcanhpyuqu96vfhn4w6p9x&**oauth_token_secret=hVhzHVVMHySB**&application_name=Application_Name&login_url=https%3A%2F%2Fapi-user.netflix.com%2Foauth%2Flogin%3Foauth_token%3Dsafcanhpyuqu96vfhn4w6p9x I am trying to parse out the value for oauth_token_secret. I need everything from the equals sign ...

java stringbuffer declaration

When I don't include the commented line, prevLineBuffer contains "null." When i do include the commented line it still works, but prints an empty string. Does Java statically allocate space for the declared string and then dynamically allocate space for an additional string in the commented line? Both appear to work... public class Inde...

Byte array to UTF8 CString

Hi all, I'm using Visual Studio 2008 (C++). How do I create a CString (in a non-Unicode app) from a byte array that has a string encoded in UTF8 in it? Thanks, kreb EDIT: Clarification: I guess what I'm asking is.. CStringA doesn't seem to be able to interpret a UTF8 string as UTF8, but rather as ASCII or the current codepage (I th...

c# longest common words sample

i am looking for a longest common words c# implementation. Most of the samples i have came across are comparing character by character. in otherwords, string1 = access string2 = advised should return null output from the function any sample codes? ...

Replace javascript on a site with Greasemonkey

Hello, does anyone know how to replace JavaScript on a site with Greasemonkey ie. This is the default code: var Test="1"; And i want to replace it like this on the page load: var Test="2"; Thanks in advance! ...

How to convert string to base64 byte array, would this be valid?

Hi, I'm trying to write a function that converts a string to a base64 byte array. I've tried with this approach: public byte[] stringToBase64ByteArray(String input) { byte[] ret = System.Text.Encoding.Unicode.GetBytes(input); string s = Convert.ToBase64String(input); ret = System.Text.Encodin...

Count html links in a string and add a list

Hi. I store the content of a website in a string $html. I want to count all html links that link to a file in the .otf format, add a list of these links to the end of $html and remove the original links. An example: <?php $html_input = ' <p> Lorem <a href="font-1.otf">ipsum</a> dolor sit amet, consectetur <a href="http://ww...

php string function concat

$contents = "<?xml version='1.0' ?> <authed>1</authed> <book>read</book>"; im having a xml string like this i want to add all the elements inside root tag like this $contents = "<?xml version='1.0' ?> <root> <authed>1</authed> <book>read</book> </root>"; ...

In Ruby how do I generate a long string of repeated text?

What is the best way to generate a long string quickly in ruby? This works, but is very slow: str = "" length = 100000 (1..length).each {|i| str += "0"} I've also noticed that creating a string of a decent length and then appending that to an existing string up to the desired length works much faster: str = "" incrementor = "" lengt...

Splitting a string at every n-th character

In JavaScript this is how we can split a string at every 3-rd character "foobarspam".match(/.{1,3}/g) I am trying to figure out how to do this in Java. Any pointers? ...

Getting the available languages of the application dynamically

Is it possible to find dynamically what are the languages supported by the application? For example, I have strings for the following languages: English, French, Dutch and German. They are defined in their corresponding res directories: values, values-fr, values-nl and values-de. I want to give the user the possibility to choose between ...

Remove part of a string from a variable jquery

I'm trying to take the id of a mouseover and strip out part of the ID, to leave me with just the core text I need to act on. My mouseover will return an id such as "nevadaActiveArea", but I need to manipulate that string down to just "nevada". All the searches I've run speak to how to do this on the contents of some element, but I just ...

Combining words in Python (permutations?)

Suppose I have 4 words, as a string. How do I join them all like this? s = orange apple grapes pear The result would be a String: "orangeapple/orangegrapes/orangepear/applegrapes/applepear/grapespear/orangeapplegrapes/orangeapplepear/applegrapespear" I am thinking: list_words = s.split(' ') for l in list_words: And then use enum...

C# How to replace parts of one string with parts of another

Using C#, what's the most efficient way to accomplish this? string one = "(999) 999-9999"; string two = "2221239876"; // combine these into result result = "(222) 123-9876" String one will always have 9's. I'm thinking some kind of foreach on string one and when it sees a 9, replace it with the next character in string two. Not qui...