I am about to begin writing an app that handles adding new users/repostories to my subversion server, so that I don't have to repeatedly open vi and edit conf files and execute shell commands.
Most of my experience centers around C, C++, Objective-C and Java. Java seems decent for string manipulations with its tokenizer class, however I...
I have a simple task I need to perform in Python, which is to convert a string to all lowercase and strip out all non-ascii non-alpha characters.
For example:
"This is a Test" -> "thisisatest"
"A235th@#$&( er Ra{}|?>ndom" -> "atherrandom"
I have a simple function to do this:
import string
import sys
def strip_string_to_lowercase(s...
I have a path as a string in a shell-script, could be absolute or relative:
/usr/userName/config.cfg
or
../config.cfg
I want to extract the file name (part after the last /, so in this case: "config.cfg")
I figure the best way to do this is with some simple regex?
Is this correct? Should or should I use sed or awk instead?
Shell...
I have a program that gets a string from a method.
I want to know how to insert a string value to that string at certain positions.
For example:
mystring = "column1 in('a','b')column2 in('c','d')column3 in('e','f')";
Here, how would I insert the string value " and " after every occurance of the character ')' in mystring?
PS. If po...
I have a variable that stores a Unix path, for example:
typeset unixpath=/foo/bar/
And I have to convert it to a DOS path using Korn shell scripting:
dospath=\\foo\\bar\\
...
Does the .NET String.Format method allow placement of a string at a fixed position within a fixed length string.
" String Goes Here"
" String Goes Here "
"String Goes Here "
How is this done using .NET?
Edit - I have tried Format/PadLeft/PadRight to death. They do not work. I don't know why. I ended up...
I am writing a mad libs program for fun and to just program something. The program itself is pretty straight forward, but I find myself resorting to several concatenations due to the nature of the game where you place user given words into a sentence. Is there an elegant work around to resort to less concatenations or even eliminate them...
When using re.sub, how to you handle a situation where you need a capture followed by a number in the replacement string? For example, you cannot use "\10" for capture 1 followed by a '0' character because it will be interpreted as capture 10.
...
How do I replace \n with empty space? i get an empty literal error if I do this:
string temp = mystring.Replace('\n', '');
...
I'm looking for a good tutorial on how to do string manipulation with stringstream in C++. Currently, I'm doing the following:
double d = 7.234;
stringstream out;
out.width(8);
out.precision(6);
out << fixed << d;
I like this link for a list of what options are available, but I learn best from examples and would like to see some more...
Briefly:
I'm after the equivalent of .NET's String.Trim in C using the win32 and standard C api (compiling with MSVC2008 so I have access to all the C++ stuff if needed, but I am just trying to trim a char*).
Given that there is strchr, strtok, and all manner of other string functions, surely there should be a trim function, or one t...
Is there any way for a C++ programmer with 1,5 years of experience to have no idea that null-terminated strings exist as a concept and are widely used in a variety of applications? Is this a sign that he is potentially a bad hire?
...
Hello,
I am essentially trying to replicate the same features as SQL Management Studio's Results To Text, to prettify my DataSet/DataReader object into a string based table.
I am looking for a free (GNU or BSD/MIT licensed or equivalent) utility code if existing which will let me print out data in a tabular format. I am appending to ...
I've been using this for some time:
SUBSTRING(str_col, PATINDEX('%[^0]%', str_col), LEN(str_col))
However recently, I've found a problem with columns with all "0" characters like '00000000' because it never finds a non-"0" character to match.
An alternative technique I've seen is to use TRIM:
REPLACE(LTRIM(REPLACE(str_col, '0', ' ')...
I'm using std::string and need to left pad them to a given width. What is the recommended way to do this in C++?
Sample input:
123
pad to 10 characters.
Sample output:
123
(7 spaces, prior to 123)
...
I want to search for a given string, within another string (Ex. find if "something" exists inside "something like this". How can I do the following? :
Know the position in which "something" is located (in the curr. ex. this is = 0.
Extract everything to the left or to the right, up to the char. found (see 1).
Extract a substring beggin...
Here's a simple problem. I have an application that takes a phone number like "13335557777", and needs to reverse it and insert a dot between each number, like this:
"7.7.7.7.5.5.5.3.3.3.1."
I know I can do this with a StringBuilder and a for-loop to reverse the string and insert the dots, but is there a clever way to do this in LINQ ...
Yes/no-question: Is there a Groovy GDK function to capitalize the first character of a string?
I'm looking for a Groovy equivalent of Perl's ucfirst(..) or Apache Commons StringUtils.capitalize(str) (the latter capitalizes the first letter of all words in the input string).
I'm currently coding this by hand using ..
str = str[0].toUpp...
I have a group of text based rules that are structured like this:
Rule 1: Do [XXX] when [PN] greater than [N]
Rule 2: Get [PRD ..] and add [X.XX]
To go with this is an array of data that translates each grouped code into a CSS class ID (for jQuery).
I also have an array of translations from [code] to ID stored in a simple structured...
That's what I've written so far:
string omgwut;
omgwut = textBox1.Text;
omgwut = omgwut.Replace(" ", "snd\\space.wav");
omgwut = omgwut.Replace("a", "snd\\a.wav");
Now, the problem is that this code would turn
"snd\space.wav"
into
"snd\spsnd\a.wavce.wsnd\a.wavv"
in line four. Not what I'd want! Now I know I'm not good at C#, s...