I have lots of strings in a text file, like this:
"/home/mossen/Desktop/jeff's project/Results/FCCY.png"
"/tmp/accept/FLWS14UU.png"
"/home/tten/Desktop/.wordi/STSMLC.png"
I want to get only the file names from the string as I read the text file line by line, using a bash shell script. The file name will always end in .png and will al...
Hi,
I have a large file where each line contains space-separated integers. The task is to sparse this file line-by-line. For the string to int conversion I have three solutions:
static int stringToIntV1(const string& str) {
return (atoi(str.c_str()));
}
However, if I pass a malformed string, it doesn't produce any error. For inst...
I need to check if a webpage exists if it does whether a certain string exists anywhere on the page.
Preferably I'd like to do this without a webbrowser control, so that images don't have to be downloaded and it doesn't have to be rendered.
So is there a way to do this?
...
This is a question of best practices. I have a utility that takes in a two digit year as a string and I need to convert it to a four digit year as a string. right now I do
//DOB's format is "MMM (D)D YY" that first digit of the day is not there for numbers 1-9
string tmpYear = rowIn.DOB.Substring(rowIn.DOB.Length - 3, 2); //-3 because ...
In a loop running over the entire string how do i peek at the next value of iterator?
for (string::iterator it = inp.begin(); it!= inp.end(); ++it)
{
// Just peek at the next value of it, without actually incrementing the iterator
}
This is quite simple in C,
for (i = 0; i < strlen(str); ++i) {
if (str[i] == str[i+1]) {
...
I have a directory for which I want to list all the .doc files with a ";"
I know the following batch command echos all the files
for /r %%i In (*.doc) DO echo %%i
But know I want to put them all in a variable, add a ';' in between and echo them all at once.
How can I do that?
set myvar="the list: "
for /r %%i In (*.doc) DO <what?>
e...
I feel daft asking this, but it's driving me potty. How can I make this string:
Children\''s Toy
Suitable for insert to a MySQL database and escape the characters properly?
Thanks
...
Is there any way to check the format string at compile time ?
Example:
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com", "cool");//this will run
//this will give an exception as only one argument is supplied
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com");
Exception:"Index (zero based) must b...
I have a Hashtable of type Hashtable
I've loaded several strings as keys, one of which is "ABCD"
However, later when I go to look up "ABCD", the Hashtable returns null instead of the associated object. Further the keyset contains "ABCD", but a request to containsKey("ABCD") returns false.
Is this because String objects are inherently ...
I've got a table full of events, and I'm trying to get the number of events which are on at each hour. So that it is easy to see the number of concurrent events.
To do this, I'm running through the table looking for the event divs (which sit inside td), and then get the start and duration, and put that into a seperate div, adding them ...
Okay this one might be a bit tricky.
What would be the best way to check if a string contains only whitespaces?
The string is allowed to contain characters combined with whitespaces, but not only whitespaces.
...
I'm looking for the one liner here, starting with:
int [] a = {1, 2, 3};
List<int> l = new List<int>(a);
and ending up with
String s = "1,2,3";
...
$string = 'I like banana, banana souffle, chocobanana and marshmellows.";
$arr = some_function($string);
// $arr = ('banana'=>3,'I'=>1,'like'=>1....);
do you have an idea how to do this most efficiently?
...
I am developing a Lua library in which I needed to uppercase the first letter of a given string. Hence I created the following function:
local capitalize = function(s)
return string.gsub (s,
"(%w)([%w]*)",
function (first, rest)
return string.upper(first) .. rest
end,
1 )
end
This initially was an "internal" ...
Hello,
I have the following in my string "1406984110015" what I would like is to get;
str1 = 14
str2 = 06
str3 = 84
I am creating a function in ORACLE that would in this case return 14.06.84
Any ideas?
...
Hi,
In the following rules for the case when array decays to pointer:
An lvalue [see question 2.5] of type array-of-T which appears in an expression decays (with three exceptions) into a pointer to its first element; the type of the resultant pointer is pointer-to-T.
(The exceptions are when the array is the operand of a sizeo...
#include <stdio.h>
#define MAXLINES 5000 /* Maximum number of lines to display. */
char *lineptr[MAXLINES]; /* Pointer to input lines. */
#define BUFFERSIZE 1000
#define DEFAULT_LAST 10
int readlines(char *lineptr[], char *buffer, int maxlines);
static void unwrap(char *buffer, int index);
static void reverse(char *lineptr[...
Is there any .Net library to remove all problematic characters of a string and only leave alphanumeric, hyphen and underscore (or similar subset) in an intelligent way? This is for using in URLs, file names, etc.
I'm looking for something similar to stringex which can do the following:
A simple prelude
"simple English".to_url =...
I know that there are already several questions on StackOverflow about std::string versus std::wstring or similar but none of them proposed a full solution.
In order to obtain a good answer I should define the requirements:
multiplatform usage, must work on Windows, OS X and Linux
minimal effort for conversion to/from platform specif...
Can anybody help me understand how this string tokenizer works by adding some comments into the code? I would very much appreciate any help thanks!
public String[] split(String toSplit, char delim, boolean ignoreEmpty) {
StringBuffer buffer = new StringBuffer();
Stack stringStack = new Stack();
for (int i = 0; i < toSplit....