string

Why is string.Empty more efficient than "" in .Net

I am certain that string.Empty is more efficient than using "" in .Net languages. What I would like to know is WHY is it more efficient? ...

exact String check (WPF Multitouch)

hi, I'm trying to get you into the picture firstly, I'm trying to implement a gesture in WPF4 VS2010, it is like you move your finger until it crosses a TouchPoint that you already passed by with the SAME finger , so my thought is to make a list and check for every new TouchPoint if it exists , if yes then you have done your gesture , if...

how to replace special characters with the ones they're based on in PHP?

How do I replace: "ã" with "a" "é" with "e" in PHP? Is this possible? I've read somewhere I could do some math with the ascii value of the base character and the ascii value of the accent, but I can't find any references now. thanks ...

Help with JYTHON 2.0 CODE -STRING MANIPULATION and replace

As i have already asked this question and i have later realized that tool for which iam writing JYTHON CODES supports presently on till 2.1 version as the intepreter is of 2.1 so some of the advanced technique is not working. Now being a new and excited to learn more in jython so that ican write more better and sma...

Concat string in IsNullOrEmpty parameter

I was looking at a piece of code I wrote in C#: if(string.IsNullOrEmpty(param1) && string.IsNullOrEmpty(param2) && string.IsNullOrEmpty(param3)) { // do stuff } and decided to make it more readable/concise if(string.IsNullOrEmpty(param1+param2+param3)) { // do stuff } But looking at it I can't help but cringe. What ar...

How to trim leftmost and rightmost whitespaces of a string using PHP?

What function can I use? ...

string.Empty.StartsWith(((char)10781).ToString()) always returns true?

I trying to handle to following character: ⨝ (http://www.fileformat.info/info/unicode/char/2a1d/index.htm) If you checking whether an empty string starting with this character, it always returns true, this does not make any sense! Why is that? // visual studio 2008 hides lines that have this char literally (bug in visual studio?!?) so ...

How to convert a string value to a variable in javascript?

var test1; $(document).ready(function () { test1 = $("#test1ID").jQueryPlugin(); }); var test2; $(document).ready(function () { test2 = $("#test2ID").jQueryPlugin(); }); ... This is done so we could just do test1.foo()... foo is a function inside the jQueryPlugin that is accessible using test1.foo() syntax; So we have an arr...

string.replace var output

Hi could some one show me how to do the following: var regep = /margin-bottom:([^;]+); margin-left:0px; margin-right:0px; margin-top:([^;]+);/; elementCSS = elementCSS.replace( regep , "margin-bottom:\\1; margin-left:auto; margin-right:auto; margin-top:\\2;"); \1 to = ([^;]+) (margin-bottom) and \2 to = ([^;]+) (margin-top) ?? Cant s...

How to override ord behaivour in Python for str childs?

I have this class: class STR(str): def __int__(self): return 42 If i use it in the promt like this: >>> a=STR('8') >>> ord(a) 56 >>> int(a) 42 >>> chr(a) '*' that's the behaivour. I'd like to ord(a) be 42. How can I do it? Which method should I override in the str class? Is all this documented anywhere? Thanks! ...

Parsing a comma-delimited std::string

If I have a std::string containing a comma-separated list of numbers, what's the simplest way to parse out the numbers and put them in an integer array? I don't want to generalise this out into parsing anything else. Just a simple string of comma separated integer numbers such as "1,1,1,1,2,1,1,1,0". ...

strerror_r causes error when compiling on SunOS (C Programming)

I have a C program which compiles and runs fine under Linux without any warnings, but when trying to compile it on SunOS, I get the following warning: test.c: In function `my_function': test.c:412: warning: implicit declaration of function `strerror_r' Undefined first referenced symbol ...

Basic Java question: String equality

public class A { static String s1 = "I am A"; public static void main(String[] args) { String s2 = "I am A"; System.out.println(s1 == s2); } } Above program outputs "true". Both are two different identifiers/objects how the output is "true" ? My understanding is that the JVM will create different referenc...

simple wildcard match with std::string

I have std::string with the follwing format std::string s = "some string with @lable" I have to find all instances of '@' and then find the identifier right after the '@' , this ID has a value (in this case 'lable' stored for it in a look up table. I will then replace the @ and the id with the found value. for example suppose t...

C++ Boost: Split String

How can I split a string with Boost with a regex AND have the delimiter included in the result list? for example, if I have the string "1d2" and my regex is "[a-z]" I want the results in a vector with (1, d, 2) I have: std::string expression = "1d2"; boost::regex re("[a-z]"); boost::sregex_token_iterator i (expression.begin (), ...

how can I deal with unicode in PHP without mbstring extension

I am using a shared hosting service to host my site so I can't get direct access to PHP configuration or install any extension. So my problem is with utf-8 strings that can't be processed by standard PHP string functions since I don't have mbstring extension installed on the server. I am looking for another way to deal with unicode strin...

Int String format problem

Hi guys, I'm returning this, it is similar to how you percieve dollars, $"32.95" etc. I calculate it in cents which is an int, but the problem is the second half cuts off the 10s of cents part if the number is less than that. For example if I have "32.08" it returns as "32.8". Any ideas ? i know i need an if but i cant think how to write...

Remove whitespace in Python using string.whitespace

Python's string.whitespace is great: >>> string.whitespace '\t\n\x0b\x0c\r ' How do I use this with a string without resorting to manually typing in '\t|\n|... etc for regex? For example, it should be able to turn: "Please \n don't \t hurt \x0b me." into "Please don't hurt me." I'd probably want to keep the single spaces, but it'...

Ruby string#crypt in c# and php

I have a ruby client program that encrypts a password with string#crypt like so encrypted = password.crypt(SALT) # removing first two characters which actually are the salt for safety return encrypted[2, encrypted.size - 2] it then sends it to a server for comparison with it's stored pre-encrypted string. how ever I need to be a...

PHP: Limit a string based on specified character length and number of paragraphs.

Ok so I know limiting strings is fairly easy when it comes to simply truncating and preserving html tags and stuff... but I'm kinda brain%^$%'d when I came to this scenario: I have a div box with a fixed height. I need to limit the strings echoed inside it so that it fits. It does pretty well with preserved html tags and all but it brea...