Is there a Ruby/Rails function that will strip a string of a certain user-defined character? For example if I wanted to strip my string of quotation marks "... text... "
http://api.rubyonrails.org/classes/ActiveSupport/Multibyte/Chars.html#M000942
...
Hi,
I've a input string:
"risk management, portfolio management, investment planning"
How do I convert this string into:
"risk management" + "portfolio management" + "investment planning"
Thanks.
...
I have a function which shall return a char*. Since I have to concatenate some strings, I wrote the following line:
std::string other_text;
// ...
return ("text" + other_text).c_str();
I know that I could avoid the question naming the string I want to return. I just want to take the chance to make a more general question:
is it safe ...
I have an app written in C# that does a lot of string comparrison. The strings are pulled in from a variety of sources (including user input) and are then compared. However i'm running into problems when comparing space '32' to non-breaking space '160'. To the user they look the same and so they expect a match. But when the app does the ...
I have something like the following in a string:
blah blah
BEGINIGNORE
this stuff should get stripped out
ENDIGNORE
more stuff here
I would like to do this (perl syntax): s/BEGINIGNORE.*ENDIGNORE//s -- namely, strip out everything between BEGINIGNORE and ENDIGNORE, inclusive.
You would think the following would do that in Mathema...
Here is the question: How would your trim a block of text to the nearest word when a certain amount of characters have past. I'm not trying to limit a certain number words or letters, but limit the letters and cut it off at the nearest word.
Say I had two strings:
"This is a block of text, blah blah blah"
"this is another block of txt ...
I was wondering about StringBuilder and I've got a question that I was hoping the community would be able to explain.
Let's just forget about code readability, which of these is faster and why?
StringBuilder.Append:
StringBuilder sb = new StringBuilder();
sb.Append(string1);
sb.Append("----");
sb.Append(string2);
StringBuilder.Appen...
I'm trying to obfuscate a large amount of data. I've created a list of words (tokens) which I want to replace and I am replacing the words one by one using the StringBuilder class, like so:
var sb = new StringBuilder(one_MB_string);
foreach(var token in tokens)
{
sb.Replace(token, "new string");
}
It's pretty slow! Are there an...
Is there a smart macro in Excel (2000 upwards) to remove the last part of a string, if it has a certain separator?
If the separator is not there, the string should be preserved
For instance, for "."
abcd.1 => abcd
abcd => abcd
I guess I could write something using a combination of Instr and Mid and such, but ...
Hi,
I've been using Jquery for some time now and I have a question concerning bad/good practices. Here is the deal. Lets say we have this HTML:
<span class="а_s_trigger" id="tekst1">text1</span>
<span class="а_s_trigger" id="video1">video1</span>
<div class="a_s_songvideo" id="showvideo1">
<obj...
Have the following string i need to split.
$string = "This is string sample - $2565";
$split_point = " - ";
One:
I need to be able to split the string into two parts using a regex or any other match and specify where is going to split.
Second:
Also want to do a preg_match for $ and then only grab number on the right of $.
Any sugges...
I want to insert backslash before apostrophe in "children's world" string. Is there a easy way to do it?
irb(main):035:0> s = "children's world"
=> "children's world"
irb(main):036:0> s.gsub('\'', '\\\'')
=> "childrens worlds world"
...
$split_point = ' - ';
$string = 'this is my - string - and more';
How can i make a split using the second instance of $split_point and not the first one. Can I specify somehow a right to left search? Best simple approach?
Basically how do I explode from Right to Left. I want to pick up the last instance of " - ".
Result I need:
$ite...
Hi all,
I've got a varchar() field in SQL Server that has some carriage return/linefeeds between paragraph marks.
I'd like to turn it into properly formatted HTML.
For instance:
---------- before ----------
The quick brown fox jumped over the lazy dog. Then he got bored and went to bed. After that, he played with his friends.
...
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 Java I can pass a Scanner a string and then I can do handy things like, scanner.hasNext(), or scanner.nextInt(), scanner.nextDouble(), etc.
This allows some pretty clean code for parsing a string that contains rows of numbers.
How is this done in C# land?
If you had a string that say had:
"0 0 1 22 39 0 0 1 2 33 33"
In Java I wou...
How can i include a variable and make it part the string.
header("Location: http://www." . "$_SESSION['domainname']");
The above code doesn't work.
...
I am converting some code from another language to python. That code reads a rather large file into a string and then manipulates it by array indexing like:
str[i] = 'e'
This does not work directly in python due to the strings being immutable. What is the preferred way of doing this in python ?
I have seen the string.replace() functi...
I am trying to write a function, it has 2 parameters one is of string and another is of number datatype, my function has to place a dot after every N characters, where N is provided at run time (some number provided through number datatype). Can anybody help me out please?
...
I'm wondering if it's possible for .Net's String.Format() to split an integer apart into two sub strings. For example I have a number 3234 and I want to format it as 32X34. My integer will always have 4 or 6 digits. Is this possible using String.Format()? If so what format string would work?
P.S.
I know there is other ways to do this, ...