Im using an if statement to determine what to return in a function, but it seems to be not working the way i want it to.
function DoThis($dogs, $cats){
// do something with dogs, pet them perhaps.
$reg = $dogs[0];
$nate = $dogs[1];
if($cats = "dave"){return $reg;}
if($cats = "tom"){return $nate;}
}
$cats is a string (if that helps)...
Short version -- How do I do Python rsplit() in ruby?
Longer version -- If I want to split a string into two parts (name, suffix) at the first '.' character, this does the job nicely:
name, suffix = name.split('.', 2)
But if I want to split at the last (rightmost) '.' character, I haven't been able to come up with anything more elega...
I have run into a problem where the user enters data and if there are single quotes at all, the script errors out.
What's the best way to handle single quotes that users enter so it doesn't interfere with the jquery/javascript?
UPDATE:
I'm sending it through ajax to a database. here is the data parameter for a json ajax call.
data:...
In my code, I receive a const char array like the following:
const char * myString = someFunction();
Now I want to postprocess it as a wchar array since the functions I use afterwards don't handle narrow strings.
What is the easiest way to accomplish this goal?
Eventually MultiByteToWideChar? (However, since it is a narrow string w...
I want user to be able to manually enter format of the datetime fields in the program. I have Tedit component. For example if user enters 'HH:nn', then this is a valid datetime format string and all datetime components should change format property to this, but if he enters 'asd', it is not. Is there a quick way to check this, without wr...
Having used Java for a long time my standard method for creating long strings piece by piece was to add the elements to an array and then implode the array.
$out[] = 'a';
$out[] = 'b';
echo implode('', $out);
But then with a lot of data.
The (standard PHP) alternative is to use string concatenation.
$out = 'a';
$out .= 'b';
echo $ou...
I want the function getCategory() to return "invalid" , instead of printing the word "invalid" (i.e instead of using printf ) when input to the function is invalid (i.e.when either height or weight are lower then zero).
please help:
#include<stdio.h>
#include<conio.h>
char getCategory(float height,float weight)
{
char invalid = '\0';
...
Hi guys, I have a problem with some excel code that I am having trouble getting my head around.
Okay so I am using the application.evaluate command in excel vba, office 2007.
If i have Evaluate("SIN(45)") it returns a nice predicted number. However if I do Evaluate("eq") the code crashes.
eq is an equation i am reading in from excel....
-- All of the revised code still refuses to run well, please help --
When I compile my code in Windows, I get memory errors. However on the Mac, where I initially coded this code, it works fine. I need to get this working on Windows.
It's something to do with the way I handle my char strings using strcpy that the Mac seems to be fine w...
This seems so trivial but I'm not finding an answer with Google.
I'm after a high value for a string for a semaphore at the end of a sorted list of strings.
It seems to me that char.highest.ToString() should do it--but this compares low, not high.
Obviously it's not truly possible to create a highest possible string because it would a...
Hi there!
Is there any way to parse a xml string using Android SAX?
Thanks in advance,
Best regards!
...
Possible Duplicate:
Enum with strings
is is possible to have string constants in enum like
enum{name1="hmmm" name2="bdidwe"}
if it is not so what is best way to do so?
I tried it its not working for string so right now i am grouping all related constnats in one class like
class operation
{
publi...
For example, we just want to get the data inside double quotes from a list of strings:
String result = string.Empty;
List<string> strings = new List<string>();
strings.add("string=\"string\"");
strings.add("stringwithspace=\"string with space\"");
strings.add("untrimmedstring=\" untrimmed string\"");
strings.add("anotheruntrimmedstring...
Hi,
i have master-content page scenario.I have a link button on content page. that redirects to other page. but with redirection it carrying the parameters. I want to hide this querystring parameters .I tried with POST() in Form tag of master page . but that does not affecting. What have to do ?
...
Hello, this isn't a general question about read or write. I have written a program in Java to read in a text file of some metadata from images. They contain names and a long list of them sometimes over 4000 names. Unfortunately, many of these names are the same and so I wrote a program that takes the list in a .txt file and gets rid of t...
Hi Everyone ,
I have written a small program to replace a set of characters , but i also want two or more replace command in a single program .
Apart from it i also want to add an bracket after random set of characters.
This is my Program
file_read=open('<%=odiRef.getOption("READ")%>/EXPORT.XML','r')
file_write=open('<%=odiRef.ge...
How do do you say the following in regex:
foreach line
look at the beginning of the string and convert every group of 3 spaces to a tab
Stop once a character other than a space is found
This is what i have so far:
/^ +/\t/g
However, this converts every space to 1 tab
Any help would be appreciated.
...
For example, a class named Table, with its constructor being:
Table(string name="", vector <string> mods);
How would I initialize the vector to be empty?
Edit:
Forgot to mention this was C++.
...
The following C function:
int sprintf ( char * str, const char * format, ... );
writes formatted data to a string. The size of the array passed as str should be enough to contain the entire formatted string. However, what if the length of the formatted string is not known ahead of time? How can this function (or another function like ...
Simply put, if the input is always in the same case (here, lower case), and if the characters are always ASCII, can one use string::compare to determine reliably the alphabetical order of two strings?
Thus, with stringA.compare(stringB) if the result is 0, they are the same, if it is negative, stringA comes before stringB alphabetically...