string

handle null values for string when implementing IXmlSerializable interface

I have the following class that implements IXmlSerializable. When implementing WriteXml(), I need to handle the case where the string members of this class may be null values. What is the best way of handling this? Currently, I am using the default constructor in which all the string properties are initialized to empty string values. ...

jQuery: shorten string length to fit a set width.

Hello there, I have a table, and in each cell I want to place strings, but they are much wider than the cell width. To prevent line break, I would like to shorten the strings to fit the cell, and append '...' at end to indicate that the string is much longer. The table has about 40 rows and has to be done to each cell, so its important...

MASM StrCmp Undefined?

Hi, If I try to assemble the following code, I get a A2006 error ( error A2006: undefined symbol : StrCmp). Here's my code: .386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc include \masm32\include\user32.inc includeli...

C++ string template library

I want simple C++ string based template library to replace strings at runtime. For example, I will use string template = "My name is {{name}}"; At runtime, I want the name to be changed based on actual one. I found one example, www.stringtemplate.org but I little scared when its talks about antlr etc. ...

Java printf using variable field size?

I'm just trying to convert some C code over to Java and I'm having a little trouble with String.printf. In C, to get a specific width based on a variable, I can use: printf("Current index = %*d\n", sz, index); and it will format the integer to be a specific size based on sz. Trying: System.out.println(String.format("Current index =...

PHP regular expression find and append to string

I'm trying to use regular expressions (preg_match and preg_replace) to do the following: Find a string like this: {%title=append me to the title%} Then extract out the title part and the append me to the title part. Which I can then use to perform a str_replace(), etc. Given that I'm terrible at regular expressions, my code is faili...

Regex for removing leading and trailing carriage returns and line feeds from a sentence.

Also is it possible to combine this with removing periods from within the string? The sentence may have spaces which I'd like to keep. ...

string splitting question

t it returns not what i expected. i expected something like: ab cab ab what am i doing wrong? ...

how to get varchar as byte[] using DataReader in Ado.Net?

how to get varchar as byte[] data using DataReader in Ado.Net? We have tried the following code. if (!objDataReader.IsDBNull(i)) { long len = objDataReader.GetBytes(i, 0, null, 0, 0); byte[] buffer = new byte[len]; objDataR...

How to get a variable name as a string in Python?

I would like to be able to get the name of a variable as a string but I don't know if Python has that much introspection capabilities. Something like: >>> print(my_var.__name__) 'my_var' I want to do that because I have a bunch of vars I'd like to turn into a dictionary like : bar=True foo=False >>> my_dict=dict(bar=bar, foo=foo) >>>...

Get a specific string from a service list using WSDiscovery

Hello, I am using the WSDiscovery module for python. I have been able to search for services on my network. I am trying to discover a client and get the XAddress from this. The WSDiscovery module has very little documentation, actually so little the only piece is in the readme file of the module which is a few lines long. I have manged ...

How to remove list of words from strings

What I would like to do (in Clojure): For example, I have a vector of words that need to be removed: (def forbidden-words [":)" "the" "." "," " " ...many more...]) ... and a vector of strings: (def strings ["the movie list" "this.is.a.string" "haha :)" ...many more...]) So, each forbidden word should be removed from each string, a...

does javascript have literal strings?

In c# and ruby and many other languages you can denote a string as to not need escaping. in c# its like this string s = @"\whatever\this\is"; the results are when printed \whatever\this\is my question is, is this supported in any form in javascript? ...

Reading ASCII numbers using "D" instead of "E" for scientific notation using C

Hello, I have a list of numbers which looks like this: 1.234D+1 or 1.234D-02. I want to read the file using C. The function atof will merely ignore the D and translate only the mantissa. The function fscanf will not accept the format '%10.6e' because it expects an E instead of a D in the exponent. When I ran into this problem in Pytho...

Why is Java String indexOf failing?

Hi all, this must be quite simple but I am having great difficulty. You see I am trying to find a string within another string as follows. e = input.indexOf("-->"); s = input.indexOf("<!--"); input = input.replace(input.substring(s, e + 3), " "); The integers e and s are returning -1 in that it was ...

Recursively parse XmlDOcument

I have an XML document as follows: <directory> <file><monitored>0</monitored> <xferStatus>1</xferStatus> <name>test1.txt</name> <size>7</size> <created>03/31/10 11:30:02 AM</created> <modified>03/31/10 11:30:00 AM</modified> <tPathList><tPath>http://hwcdn.net/p2f4h2b5/cds/testing/test1.txt&lt;/tPath&gt; </tPathList> <tPath>http://hwcdn....

problem string recursion antlr lexer token

How do I build a token in lexer that can handle recursion inside as this string: ${*anythink*${*anything*}*anythink*} ? thanks ...

PHP: Split multibyte string (word) into separate characters

Trying to split this string "主楼怎么走" into separate characters (I need an array) using mb_split with no luck... Any suggestions? Thank you! ...

Concurrent Generation of Sequential Keys

I'm working on a project which generates a very large number of sequential text strings, in a very tight loop. My application makes heavy use of SIMD instruction set extensions like SSE and MMX, in other parts of the program, but the key generator is plain C++. The way my key generator works is I have a keyGenerator class, which holds ...

Where to split a string literal

Every time I have to split a long string literal into two (or more) pieces, because it does not fit into a single line, I have to decide if I split the text before or after a space. For example: const char * long_text1 = "This is a long text, which does not fit " "in one line"; /* or */ const char * long...