I'm trying to find the positions of all occurrences of a string in another string, case-insensitive.
For example, given the string:
I learned to play the Ukulele in Lebanon.
and the search string le, I want to obtain the array:
[2, 25, 27, 33]
Both strings will be variables - i.e., I can't hard-code their values.
I figured that th...
hello...I'm having problems removing an element from the queue. through extensive debugging I found that all the elements are being added, but when I try to remove one, it gives me the same element over and over. here is the code:
private synchronized String accessMyQueue(char[] myInput) {
String myOutput="";
myOutput=convertToSt...
Is there any recommended way to do multiple string substitutions other than doing 'replace' chaining on a string (i.e. text.replace(a, b).replace(c, d).replace(e, f) ...)?
How would you, for example, implement a fast function that behaves like PHP's htmlspecialchars in Python?
I compared (1) multiple 'replace' method, (2) the regular ex...
I have a column called Month in a stored proc which returns to me the month in string name terms (eg. January, Febuary, March etc.)
I would like to convert that to an integer.
Is that possible without just using a number of select case statements?
I would like to do this in .NET 3.5
...
I want two objects to share a single string object. How do I pass the string object from the first to the second such that any changes applied by one will be visible to the other? I am guessing that I would have to wrap the string in a sort of buffer object and do all sorts of complexity to get it to work.
However, I have a tendency...
I need to replace some characters as follows : & -> \&, # -> \#, ...
I coded as follows, but I guess there should be a much better way. Any hints?
strs = strs.replace('&', '\&')
strs = strs.replace('#', '\#')
...
...
I wrote the following example program but it crashes with segfault. The problem seems to be with using malloc and std::strings in the structure.
#include <iostream>
#include <string>
#include <cstdlib>
struct example {
std::string data;
};
int main() {
example *ex = (example *)malloc(sizeof(*ex));
ex->data = "hello world";
std::c...
Hey all
I haven't found anytihng in Google or the PHP manual, believe it or not. I would've thought there would be a string operation for something like this, maybe there is and I'm just uber blind today...
I have a php page, and when the button gets clicked, I would like to change a string of text on that page with something else.
So...
I have a situation in ASP.NET C# wherein for example I have the email address [email protected] but I need to have the @gmail.com portion removed for all email input. Please help. Thanks :)
...
i have a string="name";
i want to convert in an string array.\
how to do it?
is there any java built in function? manually i can do it but i'm searching for a java built in function
i want an array where each character of the string will be a string.
like char 'n' will be now string "n" stored in an array
...
Hi folks,
My problem is that I have a user input field, which is a textfield, and I have to convert it to a bigDecimal for use at the database.
input:
2,50 -----> 2,50
2.50 -----> 2,50
2.5 -----> 2,50
1200 -----> 1200 (or 1200,00)
1.200 -----> 1200 (or 1200,00)
1.200,50 ------> 1200,50
1,200.50 ------> 1200,50
etc.
Is there a simple w...
How do I easily convert a string containing two floats separated by a comma into a complex?
For instance:
string s = "123,5.3";//input
complex<float> c(123,5.3);//output/what I need
Is there an simpler/faster way than to split the string, read the two values and return thecomplex<float>?
...
What's the best way to visually highlight each word on the page, one at a time? I figure that the words should be broken up into an array and iterated over that way, but what's the best way to do so?
I already know how to perform string replacements and style individual elements, the trick is to do this on each word on the page, one at ...
I have a list of strings. For each string in that list, I want to prepend another string. I wrote a method to do it, but I was wondering if there was something already in .NET I could use to do this. It seems like something that could be built in, but I was not able to find anything.
Here is the method I wrote:
Private Function Prepen...
I think this may be a stupid question, but I am quite confused whether I need to escape backslash in PHP.
echo 'Application\Models\User'; prints Application\Models\User
echo 'Application\\Models\\User'; same output
echo 'Application\Model\'User'; gives Application\Model'User
So it's a escape character, shouldn't I need to escape it (\...
Hello,
From a managed c++ function I want to invoke an unmanaged function that expects a 'const char *' as an argument.
Are a) and b) below correct? For b), do I need to pin_ptr 'hello'? What about a)? Thanks.
a)
myFunction( "hello" );
b)
char hello[10] ;
strcpy( hello, "hello" );
myFunction( hello );
...
I'm trying to add a child to an XML-node by loading a string as an xml-node, but for some reason it returns an empty value ...
// Load xml
$path = 'path/to/file.xml';
$xml = simplexml_load_file($path);
// Select node
$fields = $xml->sections->fields;
// Create new child node
$nodestring = '<option>
<label>A label</label>
...
Hi guys,
I have a textView with some text in it. I want to delete the last 4 characters and then add on some more text. I tried doing this.
textViewObject.append("\b\b\b\b new text that I am adding");
But instead of the \b doing a backspace, they show up as little squares in the textfield. Can anyone help me out here?
...
I have a two strings, word and text. text is generated by looking at the node values of text nodes in a table. word is a string to find in text.
However, in this situation, In Google Chrome 5.0.375.125 (Official Build 53311) beta, and Firefox 3.6.8, I get the following output:
console.log(text)
st. text text text text text text te...
I need a regular expression to parse words from a sentence or a paragraph. Some separaters that should be used are: spaces, and dots. So in:
My name is Bob.I'm 104 yrs old.
Bob and I'm are seperated even though there isn't any space between them, but a dot.
Any other regular seperaters of words should also be included.
...