string-manipulation

String manipulation in XAML property databinding for Hyperlinks

Is there an easy way to transform or format a string as part of WPF data binding? Suppose I want to create a WPF Hyperlink element based on a string tag. <Hyperlink NavigateUri="{Binding Tag}"> <Run Text="{Binding Tag}" /> </Hyperlink> But I need to transform the Tag first for the NavigateUri property to make it a true hyperlink ...

Flash Lite 1.1 substring question

Could you tell me why both lines print out a? trace(substring("asd", 0, 1)); // == "a" trace(substring("asd", 1, 1)); // == "a" (this prints out s: trace(substring("asd", 2, 1)); // == "s") Does in Flash Lite 1.x the index start with 1? ...

Why is PadLeft not working?

I have the following code: string foo = "blah".PadLeft(4, ' '); But when I check it, instead of foo being "____blah" (with 4 spaces at the start), it's just "blah". Why doesn't PadLeft do what I expect? ...

PHP and character encoding problem with  character

I'm having a problem where PHP (5.2) cannot find the character 'Â' in a string, though it is clearly there. I realize the underlying problem has to do with character encoding, but unfortunately I have no control over the source content. I receive it as UTF-8, with those characters already in the string. I would simply like to remove it...

Parsing a domain name

I am parsing the domain name out of a string by strchr() the last . (dot) and counting back until the dot before that (if any), then I know I have my domain. This is a rather nasty piece code and I was wondering if anyone has a better way. The possible strings I might get are: domain.com something.domain.com some.some.domain.com Yo...

What are the alternatives to Split a string in c# that don't use String.Split()

I saw this question that asks given a string "smith;rodgers;McCalne" how can you produce a collection. The answer to this was to use String.Split. If we don't have Split() built in what do you do instead? Update: I admit writing a split function is fairly easy. Below is what I would've wrote. Loop through the string using IndexOf an...

Splitting a full name field into first and last name

I have a form with a full-name text field and I would like to break the string into a first and last name strings... I'm handling the form in Coldufusion. What is the most reliable way to achieve this? I'm assuming JavaScript is not an option since, in its absence, the form would generate an error. Any examples would be great. Thanks ...

Converting a string with a hexadecimal value to an actual hexadecimal value

I have a string like this: "00c4" And I need to convert it to a hex value like this: 0x00c4 How would I do it? ...

removing /n from list of words - python

Hi I have a list as below ['Jellicle', 'Cats', 'are', 'black', 'and', 'white,\nJellicle', 'Cats', 'are', 'rather', 'small;\nJellicle', 'Cats', 'are', 'merry', 'and', 'bright,\nAnd', 'pleasant', 'to', 'hear', 'when', 'they', 'caterwaul.\nJellicle', 'Cats', 'have', 'cheerful', 'faces,\nJellicle', 'Cats', 'have', 'bright', 'black', 'eyes...

MySQL JOIN & Split String

I want to JOIN two table. Have no problem with that. I have problem with quite different thing. Here's my code: SELECT * FROM `table1` JOIN `table2` ON `table1.`field`=`table2`.`field` ... The main issue is that table1.field is a string, comma-separated. Is there any good and fast way to split it? Update I found a function by Federi...

How to make a regular expression looking for a list of extensions separated by a space

Hello, I want to be able to take a string of text from the user that should be formated like this: .ext1 .ext2 .ext3 ... Basically, I am looking for a dot, a string of alphanumeric characters of any length a space, and rinse and repeat. I am a little confused on how to say " i need a period, string of characters and a space". But also...

Change a string based on a pattern

Hi all, I want to change a string in PHP by deleting the first and the last char but ONLY IF they are equal. Let me give some examples: ' abc ' should become 'abc' 'abc a' should become 'bc ' ' abc a' should not change How do I do it? Thanks for the help, the regex based solution works. ...

how to pick up a set of numbers from the end of lines with irregular length in R?

I need to pick up some numbers from lines with irregular length, like this: AAAAAAAAA 250.00 BBB 240.00 CCCCCCC 13.00 I need to capture 250.00, 240.00 and 13.00, but since both the numeric and character strings are irregular, I can't use "substr" for that, I think regex maybe the solution, but I dunno much about it. Can anyone help? ...

left string function in C#

Hi, What's the best way to return the first word of a string in C#? Basically if the string is hello word... I need to get hello... Thanks ...

python: cannot concatenate 'str' and 'tuple' objects (it should works!)

I have a code: print "bug " + data[str.find(data,'%')+2:-1] temp = data[str.find(data,'%')+2:-1] time.sleep(1) print "bug tuple " + tuple(temp.split(', ')) And after this my application displays: bug 1, 2, 3 Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", ...

String manipulation vs Regexps

We are often told that Regexps are slow and should be avoided whenever possible. However, taking into account the overhead of doing some string manipulation oneself (not talking about algorithm mistakes - this is a different matter), especially in PHP or Perl (maybe Java) what is the limit, in which case can we consider string manipulat...

Best way to convert hex string to string in Java?

I am returned a string in the form of "0x52 0x01 0x23 0x01 0x00 0x13 0xa2 0x00 0x40 0x53 0x2b 0xad 0x48 0x5f 0x30 0x30 0x31 0x33 0x41 0x32 0x30 0x30 0x34 0x30 0x35 0x33 0x32 0x42 0x41 0x44". I want to convert the hex string into a readable string - I am new to Java, and was going about it this way: Remove spaces and "x", then remove fi...

Ruby: easiest way to remove the first char from a string.

Example: "[12,23,987,43" What is the fastest, most efficient way to remove the "[" ? Like, maybe a chop() but for the first char. ...

Replicate the functionality of Java's "Pattern.quote" in a JavaScript RegExp

In Java, you might try to make a regular expression that would match the URL stackoverflow.com using Pattern.compile("stackoverflow.com"). But this would be wrong because the . has special meaning in regular expressions. The easiest way to fix this is to write Pattern.compile(Pattern.quote("stackoverflow.com")) which comes out to: Patter...

How do i convert a floating point string to an int in c#

I have a string: string test = "19,95"; and I wan't to convert it to an int. I use: int num = Convert.Int32(test); However it throws an FormatException. And tells me that the string is not a proper string for conversion. My guess is that it has to do with the decimal seperator. How do i work around this? ...