Hello,
I want to be able to take a string of text from the user that should be formated like this:
.ext1 .ext2 .ext3 ...
Basically, I am looking for a dot, a string of alphanumeric characters of any length a space, and rinse and repeat. I am a little confused on how to say " i need a period, string of characters and a space". But also...
Hi everyone!
I'm considering of data structure for storing a large array of strings in a memory. Strings will be inserted at the beginning of the programm and will not be added or deleted while programm is running. The crucial point is that search procedure should be as fast as it can be. Saving of memory is not important. I incline to s...
Hello,
I want to replace multiple elements in my string in Objective-C.
In PHP you can do this:
str_replace(array("itemtoreplace", "anotheritemtoreplace", "yetanotheritemtoreplace"), "replacedValue", $string);
However in objective-c the only method I know is NSString replaceOccurancesOfString. Is there any efficient way to replace ...
Hi!
I have a string "foo_bar" and "foo_foo_bar". How do I remove the last "_bar" from the string? So I'm left with "foo" and "foo_foo".
Thanks
...
In perl, for numerical comparison, we have +/- inf as numbers that are greater/less than every other number. Are there also strings that are gt/lt any other string?
The reason I ask is that I'd like to tack one or the other on the end of a list of strings to ensure that a loop will terminate before the end of the list.
...
I don't understand why, but this code gives me a JavaScript error:
<script type="text/javascript">
String.prototype.format = function(values) {
var result = this;
for (var i = 0, len = values.length; i < len; i++) {
result = result.replace(new RegExp("{" + i + "}", "g"), values[i]);
}
return result;
};
alert("H...
Hello, first(as always) I want to apologize about my english, it may not be clear enough.
I'm not that good at C programming, and I was asked to read a "string" input with undefined length.
This is my solution
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *newChar();
char *addChar(char *, char);
char *readLine(void...
Hi,
i have a string table in my mysql/php table.
id | str
3 | 2,4,5,6
4 | 7,8,9,14
5 | 3,1,16
if i search with LIKE keyword for example "1" the result is below and its wrong
id | str
4 | 7,8,9,14
5 | 3,1,16
But the expected result is
id | str
5 | 3,1,16
since "1" is only in the above row but unfort...
I my web app, i have search fiedl where i get some string and a combo box.
So, i am sending two arguments to the remote function.
I want to check the user input is not null and not empty. So, then i can construct a valid query.
public ArrayList findEmployees(String str, int dep)throws ClassNotFoundException, SQLException{
System.o...
Dear all;
I need to design (and code, at some point) a "customized" string class in C++. I was wondering if you could please let me know about any documentation and design issues, primarily, and potential pitfalls I should be aware of. Links are very welcome, as are the identification of problems (if any) with current string libs (Qstri...
I'm a little confused. I am running all my inputs through a basic sanitize function I write to only allow certain characters, but characters such as [] are still being allowed.
function sanitize($input) {
$pattern = "/[^a-zA-z0-9_-]/";
$filtered = preg_replace($pattern, "", $input);
return $filtered;}
Any idea why it's doing that?
...
Hi everybody,
I'm using this function that helps my webdevelopers to find a piece of code in a webpage:
function findString (str) {
var strFound;
strFound=self.find(str);
if (strFound && self.getSelection && !self.getSelection().anchorNode ){
strFound=self.find(str);
}
if (!strFound) {
strFound=self.find(str,1,1)
...
Hi all,
I want to change a string in PHP by deleting the first and the last char but ONLY IF they are equal.
Let me give some examples:
' abc ' should become 'abc'
'abc a' should become 'bc '
' abc a' should not change
How do I do it?
Thanks for the help, the regex based solution works.
...
Hi!
I need function that will take string and integer that indicates position of non-negative double or integer and return Number or null. If there is '+' return null.
Examples
2.1 , 0 -> 2.1
+2.1 , 0 -> null
-1 , 0 -> null
-1.2 , 1 -> 1.2
qwa56sdf , 3 -> 56
What is the most elegant way to do this?
Thanks.
upd
I ...
I'm newbie in C. I want to compare string that I use '#DEFINE' and char buf[256].
This is my code.
#define SRV_SHOWMENU "SRV_SHOWMENU"
#define SRV_LOGIN_TRUE = "SRV_LOGIN_SUC"
#define SRV_LOGIN_FAIL = "SRV_LOGIN_FAIL"
#define SRV_REGISTER_OK = "SRV_REGISTER_SUC"
#define SRV_REGISTER_FAIL = "SRV_REGISTER_FAIL"
char buf[256]; // buff...
I have a c++ class with a member that is a string, something like:
class Phone {
string name;
void foo()
{
name = string("new_name");
}
}
Now, within the function "foo", I reassign the string to "new_name". My question is:
What happens to the old, empty string? Is it correctly "freed"? Does it still occupy memory?
Now I ini...
I have a string in what is the best way to put the things in between $ inside a list in java?
String temp = $abc$and$xyz$;
how can i get all the variables within $ sign as a list in java
[abc, xyz]
i can do using stringtokenizer but want to avoid using it if possible.
thx
...
I have a String^1 and I need to convert it to const char* and c_str() does not work as it is not a member of System::String. Is there a simpler way to do this other than this method? I am only doing this once and it is from an openFileDialog->Filename, so the input will not be anything complex. I am using Visual Studio 2008.
Thanks
...
I would like to compare a character literal with the first element of string, to check for comments in a file. Why use a char? I want to make this into a function, which accepts a character var for the comment. I don't want to allow a string because I want to limit it to a single character in length.
With that in mind I assumed the e...
Hi,
I wonder which of these excerpts should take less resources, when we want to see if "word" is an element of an array:
Excerpt 1 - Check variable:
<?php
function checkWord($word, $elements) {
$array = array($word => true);
foreach ($elements as $element) {
if (isset($array[$element])) return true;
}
return f...