The == is used to compare two string in shell script, however I want to compare two strings by ignoring case, how it can be done.Do we any standard command for this.
I have an 8 digit integer which I would like to print formatted like this:
XXX-XX-XXX
I would like to use a function that takes an int and returns a string.
What's a good way to do this?
Hi All,
I'm writing a program in C++ which do some special treatment for all the files in the current directory on Linux OS.
So i was thinking of using system calls such as system("ls") to get the list of all files.
but how to store it then inside my program ? ( how to redirect the output of ls to let's say a string that i declared in the program )
Thanks
I want to remove hyphens (-), slashes (/) and white space () from a string name(i) so that I can use it as a structure field name.
This is the ugly way I am currently doing it using the function strrep:
cell2mat(strrep(strrep(strrep(name(i), '-',''),'/',''),' ', ''))
I have also tried other variations, such as:
strrep(name(i),{'-','/'},{'',''});
strrep(name(i),['-','/'],['','']);
What is a more efficient way of doing this?
I'm relatively new to Java coding, and was looking for some help. I have a capital letter defined in a variable string, and I want to output the next and previous letters in the alphabet. For example, if the variable was equal to C, I would want to output B and D.
Thanks in advance for any help.
Is there any functionality in IDL that will allow it to evaluate a a string as code?
Or, failing that, is there a nice, dynamic way of including /KEYWORD in functions? For example, if I wanted to ask them for what type of map projection the user wants, is there a way to do it nicely, without large if/case statements for the /Projection_Type keyword it needs?
With even a small number of user options, the combinations would cause if/case statements to get out of hand very quickly to handle all the possible options.
so i have a list of string
{test,testertest,testing,tester,testingtest}
I want to sort it in descending order .. how do u sort strings in general ? Is it based on the length or is it character by character ??
how would it be in the example above ?? I want to sort them in a descending way.
Let's say you had a string
test = 'wow, hello, how, are, you, doing'
and you wanted
full_list = ['wow','hello','how','are','you','doing']
i know you would start out with an empty list:
empty_list = []
and would create a for loop to append the items into a list
i'm just confused on how to go about this,
I was trying something along the lines of:
for i in test:
if i == ',':
then I get stuck . . .
What's the most efficient way to pull 'en-US' out of 'form1.en-US.resx' using C#? The solution should also handle there not being culture info in the file name (ie form1.resx). In that case a string assigned "Default" should be returned.
Hi,
I have a string "hello [world] this {is} a (test)" I want to remove all text in braces, e.g. returning "hello this a". But only if the braces match.
Anyone have a nice neat solution?
How print format string passed as argument ?
example.cpp:
#include <iostream>
int main(int ac, char* av[])
{
printf(av[1],"anything");
return 0;
}
try:
example.exe "print this\non newline"
output is:
print this\non newline
instead I want:
print this
on newline
I want to assign a xml code into a string variable.
I can do this without escaping single or double-quotes by using triple-quote in python.
Is there a similar way to do this in F# or C#?
I could have sworn I used a chr() function 40 minutes ago but can't find the file. I know it can go up to 256 so I use this:
std::string chars = "";
chars += (char) 42; //etc
So that's alright, but I really want to access unicode characters. Can I do (w_char) 512? Or maybe something just like the unichr() function in python, I just can't find a way to access any of those characters.
I have an InputStreamReader object. I want to read multiple lines into a buffer/array using one function call (without crating a mass of string objects). Is there a simple way to do so?
Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution.
I've been reading the Python 3.2 docs about string formatting but it hasn't really helped me with this particular problem.
Here is what I'm trying to do:
stats = { 'copied': 5, 'skipped': 14 }
print( 'Copied: {copied}, Skipped: {skipped}'.format( stats ) )
The above code will not work because the format() call is not reading the dictionary values and using those in place of my format placeholders. How can I modify my code to work with my dictionary?
When would you ever want to scope a String Builder inside a for loop?
Sample Code:
....
for (int i=0; i<cnt; i++) {
....
{
StringBuilder sb = new StringBuilder();
sb.append(",");
....
}
}
....
Actually I have such a code:
NSString *path = [[NSBundle mainBundle] pathForResource: @"connect" ofType: @"xml"];
NSError *error = nil;
NSString *data = [NSString stringWithContentsOfFile: path
encoding: NSUTF8StringEncoding
error: &error];
NSString *message = [NSString stringWithFormat:data, KEY, COUNTRY_ID];
which reads the connect.xml from resources. But on the formating the string (message) APP quits without displaying any errors. How can I read file.xml from resources to NSString with format?
I am developing a c++ banking system.
I am able to get the float, newbal, values correctly and when I try to write to file, there is no data in the file.
else
{
file>>firstname>>lastname;
cout<<endl<<firstname<<" "<<lastname<<endl;
cout<<"-----------------------------------\n";
string line;
while (getline(file, line))
{
//stringstream the getline for line string in file
istringstream iss(line);
if (iss >> date >> amount)
{
cout<<date<<"\t\t$"<<showpoint<<fixed<<setprecision(2)<<amount<<endl;
famount+=amount;
}
}
cout<<"Your balance is $"<<famount<<endl;
cout<<"How much would you like to deposit today: $";
cin>>amountinput;
float newbal=0;
newbal=(famount+=amountinput);
cout<<"\nYour new balance is: $"<<newbal<<".\n";
file<<date<<"\t\t"<<newbal; //***This should be writing to file
but it doesn't.
file.close();
The text file looks like this:
Tony Gaddis
05/24/12 100
05/30/12 300
07/01/12 -300
//Console Output looks like this
Tony Gaddis
05/24/12 100
05/30/12 300
07/01/12 -300
Your balance is: #1
How much wuld you like to deposit: #2
Your new balance is: #1 + #2
write to file
close file.
//exits to main loop::::
How can I make it write to file and save it, and why is this happening.
I tried doing it with ostringstream as well considering how I used istringstream for the input. But it didn't work either :\
float newbal=0;
newbal=(famount+=amountinput);
ostringstream oss(newbal);
oss<<date<<"\t\t"<<newbal;
I am trying to self teach c++ so any relevant information would be kindly appreciated.
char *myfunc() {
char *temp = "string";
return temp;
}
In this piece of code, where does the allocation of the object pointed to by temp happen and what would be its scope?
Is this function a valid way to return a char* pointer?
Title says it all really. Using only XSLT 1.0's string functions, how would I go about slicing off the end of a url?
So from
http://stackoverflow.com/questions/2981175/is-it-possible-to-slice-the-end-of-a-url-with-xslt-1-0
I would like to extract
is-it-possible-to-slice-the-end-of-a-url-with-xslt-1-0
Is this possible?
When I compare two array values I see two strings that look the same. php doesn't agree.
$array1 = ('address'=>'32 Winthrop Street','state'=>'NY');
$array2 = ('address'=>'32 Winthrop Street');
$results = array_diff_assoc('$array1, $array2);
var_dump($results)
//echos ['address'] => string(18) "32 Winthrop Street" ['state']=>'NY'
Why is this?
I have a wstringstream:
wstringstream sstream;
AlterSstream(sstream);
sstream << "foo";
MessageBoxW(
NULL,
sstream.str().c_str(),
L"subject",
MB_OK
);
This outputs a long string that looks nothing like what I put in it in AlterSstream():
00000000002CEC58foo
AlterSstream:
void AlterSstream(wstringstream& outStream)
{
outStream << "odp";
}
Why is this happening?
Hi,
I'm using the permalink_fu plugin to create permalinks from titles. My problem is: If the title contains german characters, they are just replaced with '_'.
What I need is something that replaces
ä with ae
ü with ue
ö with oe
I fount String.tr but the problem here is that it replaces 1 character with 1 replacement, so it would work for replacing
é with e
ø with o
etc.
Does anyone have a nice and clean solution for that?
Thanks