string

problem with if statement used to determine function return

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)...

Ruby: Split string at character, counting from the right side

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...

Single quotes in string with jQuery ajax

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:...

What is the easiest way to convert a char array to a WCHAR array?

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...

How to check if string is a valid DateTime Format string in Delphi

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...

String concatenation vs array implode in PHP

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...

How to return string from a char function

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'; ...

problems with excel's application.evaluate command in vba

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....

Why do I not get strcpy errors on the Mac while I do on Windows?

-- 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...

C# highest string

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...

Android - Parse XML string

Hi there! Is there any way to parse a xml string using Android SAX? Thanks in advance, Best regards! ...

c#:How to use enum for storing string constants?

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...

How to use regex in a c#, specifically getting the data inside a double quote?

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...

how to hide querystring in asp.net content page?

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 ? ...

Reading in and Writing out in Java Program Question

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...

Replace Multiple lines in Jython

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...

Convert spaces to tabs in RegEx

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. ...

How to set a default parameter for a vector <string> for use in a default constructor within a class?

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++. ...

writing formatted data of unknown length to a string (C programming)

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 ...

Is string::compare reliable to determine alphabetical order?

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...