string

replacing regex in java string

I have this java string: String bla = "<my:string>invalid_content</my:string>"; How can I replace the "invalid_content" piece? I know I should use something like this: bla.replaceAll(regex,"new_content"); in order to have: "<my:string>new_content</my:string>"; but I can't discover how to create the correct regex help please :)...

Passing JSON strings larger than 80 characters

I'm having a problem passing strings that exceed 80 characters in JSON. When I pass a string that's exactly 80 characters long it works like magic. But once I add the 81st letter it craps out. I've tried looking at the json object in firebug and it seems to think the string is an array because it has an expander next to it. Clicking the ...

How do I determine the longest similar portion of several strings?

As per the title, I'm trying to find a way to programmatically determine the longest portion of similarity between several strings. Example: file:///home/gms8994/Music/t.A.T.u./ file:///home/gms8994/Music/nina%20sky/ file:///home/gms8994/Music/A%20Perfect%20Circle/ Ideally, I'd get back file:///home/gms8994/Music/, because that's th...

Comma seperated textbox value to list/array of strings - Is there a better way to write this code?

I want to create an array/list of strings of the Comma seperated strings (file extensions) that are entered in a Textbox. For the following block of code: Dim csv As String = Textbox1.Text + "," While csv.IndexOf(".") <> -1 lstOfStrings.Add(csv.Substring(0, csv.IndexOf(","))) csv...

Java Problem: Returning a string entered as reverse text

Hi, I'm trying to make a method that returns a string of words in opposite order. IE/ "The rain in Spain falls mostly on the" would return: "the on mostly falls Spain in rain The" for this i am not supposed to use any built in Java classes just basic java So far i have: lastSpace = stringIn.length(); for (int i = strin...

in Oracle 9.2, how to compare LONG Type containing String text to a Column of VARCHAR2.

simple q. in Oracle 9.2, how to compare LONG Type containing String text to a Column of VARCHAR2. select * from table1 t1, table2 t2 where t1.long_value = t2.varchar2_value how can i execute such a query the easiest way? ...

Caselessly comparing strings in C#

Let's say I have two strings: a and b. To compare whether a and be have the same values when case is ignored, I've always used: // (Assume a and b have been verified not to be null) if (a.ToLower() == b.ToLower()) However, using Reflector, I've seen this a few times in the .NET Framework: // (arg three is ignoreCase) if (string.Com...

MySQL binary against non-binary for hash IDs

Assuming that I want to use a hash as an ID instead of a numeric. Would it be an performance advantage to store them as BINARY over non-binary? CREATE TABLE `test`.`foobar` ( `id` CHAR(32) BINARY CHARACTER SET ascii COLLATE ascii_bin NOT NULL, PRIMARY KEY (`id`) ) CHARACTER SET ascii; ...

How to handle escape sequences in string literals in ANTLR 3?

I've been looking through the ANTLR v3 documentation (and my trusty copy of "The Definitive ANTLR reference"), and I can't seem to find a clean way to implement escape sequences in string literals (I'm currently using the Java target). I had hoped to be able to do something like: fragment ESCAPE_SEQUENCE : '\\' '\'' { setText("'")...

Does String.ToLower() always allocate memory?

Does String.ToLower() return the same reference (e.g. without allocating any new memory) if all the characters are already lower-case? Memory allocation is cheap, but running a quick check on zillions of short strings is even cheaper. Most of the time the input I'm working with is already lower-case, but I want to make it that way if ...

Get bytes from std::string in C++

Hi I'm working in a C++ unmanaged project. I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt. In C# I do for (int i = 0; i < text.Length; i++) buffer[i] = (byte)text[i]; What I need to know is how to do the same but using unmanaged C++....

Checking string format at compile time in C#

In my code there are several strings which are used as keys to access resources. These keys have a specific format, e.g. string key = "ABC123"; Currently, all these keys are stored as strings, but I'd like to make things more robust and type-safe. Ideally, I'd like to check the strings are in the correct format at compile time. The n...

What is the nicest way to find a specific string in vector?

For instance. I have some structure: s_Some{ std::string lable; s_some_junk some_junk; }; And a vector: std::vector<s_Some> mSome; And then I fill this vector with a lot of s_Somes. I need to find an iterator for a single s_Some in this vector, which has a specific lable. So far I just iterate through all of this junk and mat...

Why isn't String.Empty a constant?

In .Net why is String.Empty read only instead of a constant? I'm just wondering if anyone knows what the reasoning was behind that decision. ...

How can I remove all characters from string starting at first non-alpha character?

This would have been a lot easier if not for certain situations. Sample data: KENP989SD KENP913E KENPX189R KENP913 What regular expression can I use to remove all characters from the string starting at the first non-alpha character? Basically, I want to find the first non-alpha character and chop everything off after that regardless ...

How can I convert a string to an integer in C++

I am trying to copy the value in bar into the integer foo. This is what I have so far. When I run it I get a different hex value. Any help would be great. int main() { string bar = "0x00EB0C62"; int foo = (int)bar; cout << hex << foo; ChangeMemVal("pinball.exe", (void*) foo, "100000", 4); return 0; } So the ou...

ReverseString

How can I use the ReverseString function in Delphi2009? ...

Any improvements on the GCC/Windows DLLs/C++ STL front?

Yesterday, I got bit by a rather annoying crash when using DLLs compiled with GCC under Cygwin. Basically, as soon as you run with a debugger, you may end up landing in a debugging trap caused by RtlFreeHeap() receiving an address to something it did not allocate. This is a known bug with GCC 3.4 on Cygwin. The situation arises because ...

How do I compare strings in Java?

I've been using the "==" operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug. Is "==" bad? When should it and should it not be used? What's the difference? Thanks ...

Do the items in an array or list maintain their order?

I am coding VB.NET in VS2008. I have a comma delimited string of numbers, i.e. 16,7,99,1456,1,3 I do this in VB: Dim MyArr() As String = MyString.Split(",") Will MyArr keep the items in the order they were in the string? If I do this: For Each S as String in MyString.Split(",") 'Do something with S 'Will my items be in the...