I m curious why would i use string formatting while i can use concatenation such as
Console.WriteLine("Hello {0} !", name);
Console.WriteLine("Hello "+ name + " !");
Why to prefer the first one over second?
1) Is there any built-in which can tell me if a variable's contents contain only uppercase letters?
2) is there any way to see if a variable contains a string? For example, I'd like to see if the variable %PATH% contains Ruby.
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper(). What's special about string to make it better for character data?
I am getting a string from the user and then doing some checking to make sure it is valid, here is the code I have been using;
char digit= userInput.charAt(0) - '0';
This had been working fine until I did some work on another method, I went to compile and have been receiving a 'possible loss of precision' error since then.
What am I doing wrong?
Hi there,
I have a piece of text that gets handed to me like:
here is line one\n\nhere is line two\n\nhere is line three
What I would like to do is break this string up into three separate variables.
I'm not quite sure how one would go about accomplishing this in python.
Thanks for any help,
jml
How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.
Any language would work but it should be portable.
Given a string
'1.2.3.4.5'
I would like to get this output
'1.2345'
I wrote this
function process( input ) {
var index = input.indexOf( '.' );
if ( index ) {
input = input.substr( 0, index + 1 ) +
input.slice( index ).replace( /\./g, '' );
}
return input;
}
Live demo: http://jsfiddle.net/EDTNK/
It works but I was hoping for a slightly more elegant solution...
I have a string like
Pakistan, officially the <a href="Page.aspx?Link=Islamic Republic of Pakistan">Islamic Republic of Pakistan</a>
Now I am using
System.Text.RegularExpressions.Regex.Replace(inputText, "(\\bPakistan\\b)", "something");
to replace Pakistan outside the tags. But I don't want to replace Pakistan occurring within the <a></a> tags.
I'm reading a sourcefile in Java, but when I print it (sysout), the escaped characters are no longer escaped. How can I escape characters like \n and \t in a string in Java?
Hi everyone,
I am getting a difference when comparing two string which are 0 and '0' in PHP. Can I do anything to make them be compared equally in an if action?
Thanks!
Hi all!
I Use this code:
NSString* strName = [NSString stringWithFormat:@"img_00%d.jpg", pp];
and works fine, but if pp took the value of 10 for example I wish have img_010.jpg as result, and not img_0010.jpg...
how can I format the string??
thanks
What query is suitable to compare two tables specied below, however only part of string in location(table1) will matches with the Location(table2).
Location(table1) Location(table2)
india- north USxcs
India-west Indiaasd
India- east Indiaavvds
India- south Africassdcasv
US- north Africavasvdsa
us-west UKsacvavsdv
uk- east Indiacascsa
uk- south UScssca
Africa-middle Indiacsasca
Africa-south Africaccc
Africa-east UKcac
only 1st two characters of location(table1) and 1st two characters of location(table2) should match. Please help
only any four characters of location(table1)and any two characters of location(table2)should match.
string s = "????";
wstring ws = FUNCTION(s, ws);
How would i assign the contents of s to ws?
Searched google and used some techniques but they can't assign the exact content. The content is distorted.
i have a string of the format SUCCESS,12:34:56:78:90, i want to separate these two values that are separated by commas into two different strings. how do i do that in gcc using c language.
I'm building a calculator application, and I have a Form, with a TextBox called txtVisor, that has the property NumbersOnly = true. I want to get the content of it(that I already know: txtVisor.Text) and convert it into a Integer, to do multiply it by 12, then convert the result into a String to set the txtVisor.Text as the result of the operation. How could I do this?
PS: I'm using NSBasic 7.0
Hello.
This may sound easy, but I've been trying - in vain, apparently - to figure out how I can make a query with MySQL that checks if the value (string $haystack ;) ) in a certain column contains certain data ( $needle ;) ), like this:
mysql_query("
SELECT *
FROM `table`
WHERE `column`.contains('{$needle}')
");
In PHP, the function is called substr($haystack, $needle), so maybe:
WHERE substr(`column`, '{$needle}')=1
Thanks in advance!
I'm trying to remove all BBCode Tags from a string.
[url]www.google.com[/url]
becomes
www.google.com
I have a regex that works in php to find them all, just dont know how to remove them in .net
RegEx to Find BBCode
|[[\/\!]*?[^\[\]]*?]|si
I have a string that looks like this:
CALDARI_STARSHIP_ENGINEERING
and I need to edit it to look like
Caldari Starship Engineering
Unfortunately it's three in the morning and I cannot for the life of me figure this out. I've always had trouble with replacing stuff in strings so any help would be awesome and would help me understand how to do this in the future.
I get a string from a db, then I remove all the HTML tags, carriage returns and newlines, before I put it in a csv. Only thing is I cant remove the excess white space from between the strings, any ideas?
Thanks,
Joe
I would like to insert a line break into the first space between words in a string variable. Here is my code so far:
<cfset myPosition = find(" ", #myVar#)>
<cfset lineBreak = Chr(13)&Chr(10)>
<cfset myVar = insert(#lineBreak#, #myVar#, #myPosition#)>
What am I doing wrong?
I'd like to be able to parse out the city, state or zip from a string in python. So, if I entered
Boulder, Co
80303
Boulder, Colorado
Boulder, Co 80303
...
any variation of these it would return the city, state or zip.
This is all going to be user inputted data and inputted in one text field.
Right now i'm trying to get this:
Array
(
[0] => hello
[1] =>
[2] => goodbye
)
Where index 1 is the empty string.
$toBeSplit= 'hello,,goodbye';
$textSplitted = preg_split('/[,]+/', $toBeSplit, -1);
$textSplitted looks like this:
Array
(
[0] => hello
[1] => goodbye
)
I'm using PHP 5.3.2
I want to ask the user for input in console. He'll be writing down two numbers separated by a single space.
In Java is there something like the C# Split() method I can use?
Thank you!