string

How to get the substring from a String in ColdFusion

How can I get the Substring in Coldfusion? ex:- following is the String "Update Tablename set value=something where value2=thisone" I want to get the Table name from the Str how is it possible? Note:- Table name is dynamic(i.e may be any charecters). Thanks ...

How to extract a GET parameter from the URL in Javascript?

Suppose I have this url: s = 'http://mydomain.com/?q=microsoft&p=next' In this case, how do I extract "microsoft" from the string? I know that in python, it would be: new_s = s[s.find('?q=')+len('?q='):s.find('&',s.find('?q='))] ...

Full code coverage

I'm trying to obtain full code coverage for the following line of code... stringWriter.Write(HtmlEncodedString.Format(string.Format("{0,-10:C}", x + y))) The line above this one is showing as fully covered and is just writing out a string but this one is only showing as partially covered. Anybody have any ideas how I can make this l...

Search for string in text file C

The following code reads a text file one character at the time and print it to stdout: #include <stdio.h> int main() { char file_to_open[] = "text_file.txt", ch; FILE *file_ptr; if((file_ptr = fopen(file_to_open, "r")) != NULL) { while((ch = fgetc(file_ptr)) != EOF) { putchar(ch); } ...

Java Double to String conversion without formatting

I have the number 654987. Its an ID in a database. I want to convert it to a string. The regular Double.ToString(value) makes it into scientific form, 6.54987E5. Something I dont want. Other formatting functions Ive found checks the current locale and adds appropriate thousand separators and such. Since its an ID, I cant accept any for...

Split string in 512 char chunks [C#]

Hello. Maybe a basic question but lets say I have a string that is 2000 characters long, I need to split this string into max 512 character chunks each. Is there a nice way, eg. a loop for doing this? Thank you :-) ...

How to replace multiple different chars with white space?

How to replace different/multiple chars with white space for each instance of character? characters to be replaced are \ / : * ? < > | ...

Is there a reverse fn() for strstr

All, I am trying to find a similar function to 'strstr' that searches a substring starting from the end towards the beginning of the string. Thanks ...

Strings are immutable - that means I should never use += and only StringBuffer?

Strings are immutable, meaning, once they have been created they cannot be changed. So, does this mean that it would take more memory if you append things with += than if you created a StringBuffer and appended text to that? If you use +=, you would create a new 'object' each time that has to be saved in the memory, wouldn't you? ...

String parsing in Java with delimeter tab "\t" using split

I have to parse a line which is tab delimited. I parse it using the split function, and it works in most situations. The problem occurs when some field is missing, so instead of getting null in that field I get next value. I was store parsed values in a string array. String[] columnDetail = new String[11]; columnDetail = column.split("\...

"Intelligent" cast of double to two differently formatted strings?

I'm working with a database that has the limit that the only (numeric) datatype it can store is a double. What I want to do is pick the number for a certain row and put it into an HTTP request. The problem revolves around that I cannot know if this number should or should not have decimals. For example, if the double is an ID, I cannot ...

Query a dataTable by large Query String

I have a datatable that i want to query. the query is very large and complicated and it works when i run it in the SQl Server Editor - so i have the query text. i need to query the datatable with this query String. To Translate the query into linq will take years, and also Select() method of DataTable won't handle it. How can i operate...

Trimming string variables by reference in PHP5

I saw another post suggesting using this statement to trim string variables contained in the array: $_POST=array_map('trim', $_POST); However, if in the first place, the strings are not contained in an array, I would like to have a trim function that can be used like this: $a=' aaa '; $b=' bbb '; $c=' ccc '; trimAll($a,$b,$c); //a...

Select string with comma (regex)

I need an regular expression which matches the following: '"test foo bar", "test"' => no match '"test, foo bar", "test"' => "test, foo bar" '"test, foo bar"' => "test, foo bar" '"test foo bar"' => no match '"test", "test, foo"' => "test, foo" '"test", ","' => no match '"test", 0, 0, "foo"' => no match the regex should match any string...

how can convert LPCSTR string into LPCTSTR string?

i am trying to convert a LPCSTR string into LPCTSTR string. i want to concatenate two string,when i try like this LPCTSTR str1 = L"Raja" LPCSTR str2 = "Kumar" wcscat_s(str1,(LPCTSTR)str2); i found the o/p like Raja....r(junkvalues)....how can typecast LPCSTR to LPCTSTR? ...

Converting Byte recieved from the registry to String

Hello, I'm in the process of creating an application which will monitor specific registry key values for changes and write those changes to a text file. At present I can monitor the changes and know when specific values have changed and collect the data held in those values. The problem I'm having at the moment is the return type of the...

String Assignment -Clarification

When i declare string x = new string(new char[0]); It works fine.My question is what value will be assigned to x ? when i check Console.WriteLine(x.CompareTo(null)==0);,it returns false. ...

Marshalling strings, C++ to C#: 'conversion is not supported by the library'

Summary: When attempting to use marshalling to pass string data into a C++ DLL from C#, I'm getting 'msclr::interop::error_reporting_helper<_To_Type,_From_Type>::marshal_as': This conversion is not supported by the library or the header file needed for this conversion is not included. Please refer to the documentation on ...

insert string in the middle of a file given a file object

I am working on a problem and got stuck at a wall I have a (potentially large) set of text files, and I need to apply a sequence of filters and transformations to it and export it to some other places. so I roughly have def apply_filter_transformer(basepath = None, newpath = None, fts= None): #because all the raw studies in basepa...

Input string was not in a correct format vb net

This is really confusing me as I'm not doing anything with Strings. This is the details the debugger gives back to me: System.FormatException was unhandled Message=Input string was not in a correct format. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Del...