string

Different format for whole numbers and decimal

is there a way of formatting a string to show whole numbers of a decimal number if it follows 00. example show 10 if number is 10.00. but show 10.2 if number is 10.2 this is for c#, asp.net ...

Good Python modules for fuzzy string comparison?

I'm looking for a Python module that can do simple fuzzy string comparisons. Specifically, I'd like a percentage of how similar the strings are. I know this is potentially subjective so I was hoping to find a library that can do positional comparisons as well as longest similar string matches, among other things. Basically, I'm hoping...

Interop sending string from C# to C++

I want to send a string from C# to a function in a native C++ DLL. Here is my code: The C# side: [DllImport(@"Native3DHandler.dll", EntryPoint = "#22", CharSet = CharSet.Unicode)] private static extern void func1(byte[] path); public void func2(string path) { ASCIIEncoding encoding = new ASCIIEncoding(); byte[] arr = encodi...

How to get random string with spaces and mixed case?

Hi all, I am in need of generating a random string with spaces and mixedCase. This is all I got so far: /// <summary> /// The Typing monkey generates random strings - can't be static 'cause it's a monkey. /// </summary> /// <remarks> /// If you wait long enough it will eventually produce Shakespeare. /// </rema...

PHP removing text in a link

How do you strip/remove wording in PHP? I have a form that's passing a full URL link to an output page. Example: maps/africa.pdf And on the output page, I want to provide an "href link", but in PHP use that same posted URL, but strip off the "maps" and have it provide a link that just says africa. Example: africa can this be done?...

How do I check a table to see if a string is already in use?

I am using this code to check my username column (username is primary) in my userdb table to see whether or not the string is already there. If it isn't there then it adds the string entered from a previous form into the username column in my table. But if it is there then it says "(Username) is already in use!". This works when I put a...

ASP.NET MapPath

I have a portion of code like this: Process proc = null; try { proc = new Process(); string dir = HttpContext.Current.Server.MapPath("~/Other/"); proc.StartInfo.WorkingDirectory = dir; p.StartInfo.FileName = "batch.bat"; p.StartInfo.CreateNoWindow = true; p.Start(); p.WaitForExit(); } catch (Exception e) { } ...

Regular Expression (Java)

How do I match the following string? http://localhost:8080/MenuTest/index.action The regex should return true if it contains "MenuTest" in the above pattern. Cheers ...

Content of Binary Output File Created With Output Stream

Dear all, This code compiles and does execute. It simply print the content into a binary format. However the output differs from what I expected, namely: Output file size should be much smaller that those created with std::cout. The content of output file should be compressed, hence when we open it in editor, we should not be able to...

How would you get an array of Unicode code points a .NET String?

BACKSTORY: I have a list of character range restrictions that I need to check a string against, but the char type in .NET is UTF-16 and therefore some characters become wacky (surrogate) pairs instead. Thus when enumerating all the char's in a string, I don't get the 32-bit Unicode code points and some comparisons with high values fail....

firefox won't convert string to number in flex

I making a web app in Flex using global coordinates I get the coordinates as strings from a web service then I do something like this: latStr:String = "28.7242100786401"; longStr:String = "-106.12635420984"; var cLat:Number = new Number(latStr); var cLong:Number = new Number(longStr); This works PERFECT on IE and chrome, from the we...

How to see if a substring exists inside another string in Java 1.4

How can I tell if the substring "template" exists inside a String in java 1.4 It would be great if it was a non case sensitive check. Thanks! ...

How can I build a std::vector<std::string> and then sort them?

I have a bunch of strings that I need to sort. I think a std::vector would be the easiest way to do this. However, I've never used vectors before and so would like some help. I just need to sort them alphanumerically, nothing special. Indeed, the string::compare function would work. After that, how can I iterate through them to verify ...

How to communicate between a JSP filter and a JAVA program

Is there any way to send a string to a JAVA program from a JSP filter? I tried sockets; didn't work. I tried external files; didn't work. So, I'm kind of at a Witt's end here on the subject. ...

Interop sending string from C# to C++

Duplicate of http://stackoverflow.com/questions/683013/interop-sending-string-from-c-to-c I want to send a string from C# to a function in a native C++ DLL. Here is my code: The C# side: [DllImport(@"Native3DHandler.dll", EntryPoint = "#22", CharSet = CharSet.Unicode)] private static extern void func1(string str); public void func2(...

Convert complex bool condition from string to bool in .NET

I need to parse complex expresion from string to bool. It can only contain: * boolean values (true/false), * parenthesis, * AND/OR operands (&&, ||) Eg: bool.Parse("((true || false) && (false || false)) || (true || false)" Any idea how to achieve this? ...

Does this function exist in PHP?

I found myself needing this function, and was wondering if it exists in PHP already. /** * Truncates $str and returns it with $ending on the end, if $str is longer * than $limit characters * * @param string $str * @param int $length * @param string $ending * @return string */ function truncate_string($str, $length, $ending = ".....

C/C++: Optimization of pointers to string constants

Have a look at this code: #include <iostream> using namespace std; int main() { const char* str0 = "Watchmen"; const char* str1 = "Watchmen"; char* str2 = "Watchmen"; char* str3 = "Watchmen"; cerr << static_cast<void*>( const_cast<char*>( str0 ) ) << endl; cerr << static_cast<void*>( const_cast<char*>( str1 ) )...

How can I permit tab characters in a textfield in Flash?

I am working on an AS3 Flash game that initially takes a input from a barcode scanner. The data that it scans comes in as one long string using tabs to separate the data segments. The scanner acts as a keyboard and inputs the string into a hidden textfield so that I can grab the string and split it apart to get the data. The input and...

Query will not run with variables, will work when variable's definitions are pasted in.

This is a Query in VBA (Access 2007) I have 3 strings defined: str_a = "db.col1 = 5" str_b = " and db.col2 = 123" str_c = " and db.col3 = 42" Then I use these in the WHERE part of my Query: "WHERE '" & str_a & "' '" & str_b & "' '" & str_c & "' ;" This fails, but If I paste in the strings like this: "WHERE db.col1 = 5 and db.col2 ...