.NET String.Replace
I am so annoyed. Typically I like replace acting as it does in C# but is there a C++ styled replace where it only replaces one letter at a time or the X amount I specify? ...
I am so annoyed. Typically I like replace acting as it does in C# but is there a C++ styled replace where it only replaces one letter at a time or the X amount I specify? ...
Consider the following code: string[] s = new[] { "Rob", "Jane", "Freddy" }; string joined = string.Join(", ", s); // joined equals "Rob, Jane, Freddy" For UI reasons I might well want to display the string "Rob, Jane or Freddy". Any suggestions about the most concise way to do this? Edit I am looking for something that is concis...
In a MySQL database, I have a table which contains itemID, itemName and some other fields. Sample records (respectively itemID and itemName): vaX652bp_X987_foobar, FooBarItem X34_bar, BarItem tooX56, TOOX_What I want to write a query which gives me an output like: 652, FooBarItem 34, BarItem 56, TOOX_What In other words,...
This is driving me crazy. I have the following string in a ASP.NET 2.0 WebForm Page string s = "0.009"; Simple enough. Now, if my culture is Spanish - which is "es-ES" - and I try to convert the string to Double, I do the following: double d = Double.Parse(s, new CultureInfo("es-ES")); what I'd expect is 0,009. Instead, I get 9. I ...
How can i include a variable and make it part the string. header("Location: http://www." . "$_SESSION['domainname']"); The above code doesn't work. ...
Hello, I need to check for a string located inside a packet that I receive as byte array.If I use BitConverter.ToString() ,I get the bytes as String with dashes(example 00-50-25-40-A5-FF). I tried most function I found after a quick googling,but most of them have input parameter type string and if I call them with the string with dashes...
We've got some fraction information stored in the database, e.g. ¾ ½ Short of doing a search and replace, are there any inbuilt PHP functions that will automatically convert these to proper html entities? ...
I've a question about Fortran 77 and I've not been able to find a solution. I'm trying to store an array of strings defined as the following: character matname(255)*255 Wich is an array of 255 strings of length 255. Later I read the list of names from a file and I set the content of the array like this: matname(matcount) = mname ...
I have a large number of name - value pairs (approx 100k) that I need to store in some sort of cache (say a hash map) where the value is a string with an average of about 30k bytes in size. Now I know for a fact that a large number of the values have exactly the same string data. In order to avoid having to allocate the identical strin...
Hi all. I've always use String.IsNullOrEmpty to check for a empty string. It recently come to my attention that a " " count as not a empty string. For example, Dim test As String = " " If String.IsNullOrEmpty(test) Then MessageBox.Show("Empty String") Else MessageBox.Show("Not Emtpy String") End If It wi...
Is there a way to associate a string from a text file with an enum value? The problem is, I have a few enum values stored as string in a text file which I read on the fly on meeting some condition... Now I want to assign the read value to an enum. What is the most effective way to do so? It needn't be the simplest approach. ...
How do I sort an ArrayList of String:s in length-of-string order in Groovy? Code: def words = ['groovy', 'is', 'cool'] // your code goes here: // code that sorts words in ascending length-of-word order assert words == ['is', 'cool', 'groovy'] There are certainly more than one way to do it - so I'll grant the answer to the person who ...
In Java how can you convert a String that represents a fragment of XML for insertion into an XML document? e.g. String newNode = "<node>value</node>"; // Convert this to XML Then insert this node into an org.w3c.dom.Document at as the child of a given node? ...
Hello, I have a listView on my form.I want to add stuff to it durring the program is running. This is the code I use public void FillList(string[] Name,int[] empty,int[] Population,int[] Max,int[] Check,int size) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { ...
I've got a table with a large number of rows that is not suitable for paging. The rows in this table can be sorted by clicking a column header which triggers a client side sorting algoritm based on http://www.exforsys.com/tutorials/jquery/jquery-basic-alphabetical-sorting.html The function dynamically adds an "expando" property to each r...
So lets say I have an object that it stored in a Database: com.test.dummy.Cat The cat has an integer id. Outside of my "world" the reference to the object is a String of the form: Cat-433 Where 433 is the Cats assigned Database ID. When I get the String passed to me, I need to be able to find it in the Database. So I do this: St...
EDIT: Can anyone help me out with a regular expression for a string such as this?: [Header 1], [Head,er 2], Header 3 so that I can split this into chunks like: [Header 1] [Head,er 2] Header 3 I have gotten as far as this: (?<=,|^).*?(?=,|$) Which will give me: [Header 1] [Head ,er 2] Header 3 Thanks!! ...
We had the following code previous to Delphi 2009: function MemoryStreamToString(M: TMemoryStream): String; var NewCapacity: Longint; begin if (M.Size = 0) or (M.Memory = nil) then Result:= '' else begin if TMemoryStreamProtected(M).Capacity = M.Size then begin NewCapacity:= M.Size+1; TMemoryStreamProtec...
I need to send email notifications to users and I need to allow the admin to provide a template for the message body (and possibly headers, too). I'd like something like string.Format that allows me to give named replacement strings, so the template can look like this: Dear {User}, Your job finished at {FinishTime} and your file is av...
I'm curious if any developers use string.IsNullOrEmpty() more often with a negative than with a positive e.g. if (!string.IsNullOrEmpty()) This is how I use the method 99% of the time. What was the design decision for this? ...