Search Results

Search found 35327 results on 1414 pages for 'string concatenation'.

Page 92/1414 | < Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >

  • String date time format

    - by Phil
    Hi i am using the vimeo API and i want to convert the string to a short date formate {0:d} or {0:dd/mm/yyyy}. This is my code but doesnt seem to be working for me. select new VimeoVideo { Date = String.Format("{0:d}",(item.Element("upload_date").Value)), }; return Vids.ToList(); } public class VimeoVideo { public string Date { get; set; } } Any help would be much appreciated Thanks

    Read the article

  • Convert string from getline into a number

    - by haskellguy
    I am trying to create a 2D array with vectors. I have a file that has for each line a set of numbers. So what I did I implemented a split function that every time I have a new number (separated by \t) it splits that and add it to the vector vector<double> &split(const string &s, char delim, vector<double> &elems) { stringstream ss(s); string item; while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; elems.push_back(number); } return elems; } vector<double> split(const string &s, char delim) { vector<double> elems; split(s, delim, elems); return elems; } After that I simply iterate through it. int main() { ifstream file("./data/file.txt"); string row; vector< vector<double> > matrix; int line_count = -1; while (getline(file, row)) { line_count++; if (line_count <= 4) continue; vector<double> cols = split(row, '\t'); matrix.push_back(cols); } ... } Now my issues is in this bit here: while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; Where item.c_str() is converted to a 0. Shouldn't that be still a string having the same value as item? It works on a separate example if I do straight from string to c_string, but when I use this getline I end up in this error situation, hints?

    Read the article

  • Python: replace urls with title names from a string

    - by Hellnar
    Hello I would like to remove urls from a string replace them with their titles of the original contents. For example: mystring = "Ah I like this site: http://www.stackoverflow.com. Also I must say I like http://www.digg.com" sanitize(mystring) # it becomes "Ah I like this site: Stack Overflow. Also I must say I like Digg - The Latest News Headlines, Videos and Images" For replacing url to the title, I have written this snipplet: #get_title: string -> string def get_title(url): """Returns the title of the input URL""" output = BeautifulSoup.BeautifulSoup(urllib.urlopen(url)) return output.title.string

    Read the article

  • ruby parametrized regular expression

    - by astropanic
    I have a string like "{some|words|are|here}" or "{another|set|of|words}" So in general the string consists of an opening curly bracket,words delimited by a pipe and a closing curly bracket. What is the most efficient way to get the selected word of that string ? I would like do something like this: @my_string = "{this|is|a|test|case}" @my_string.get_column(0) # => "this" @my_string.get_column(2) # => "is" @my_string.get_column(4) # => "case" What should the method get_column contain ?

    Read the article

  • Good way to parse query string

    - by m.edmondson
    I have a String that contains the following: ?workarea=London+&+Home+Counties+Ltd&sub=fs&&&FASh*5 which resembles a URI query string. What is the best way to parse the elements of this string (workarea and sub) without messing about with string manipulation? If I use HttpUtility.ParseQueryString is gets stuck as both elements include &. However if I encode the whole thing first I lose the seperations of the elements. Ideally the output would be: workarea = London & Home Counties Ltd sub = fs&&&FASh*5

    Read the article

  • Scala : cleanest way to recursively parse files checking for multiple strings

    - by fred basset
    Hi All, I want to write a Scala script to recursively process all files in a directory. For each file I'd like to see if there are any cases where a string occurs at line X and line X - 2. If a case like that occurs I'd like to stop processing that file, and add that filename to a map of filenames to occurrence counts. I just started learning Scala today, I've got the file recurse code working, and need some help with the string searching, here's what I have so far: import java.io.File import scala.io.Source val s1= "CmdNum = 506" val s2 = "Data = [0000,]" def processFile(f: File) { val lines = scala.io.Source.fromFile(f).getLines.toArray for (i = 0 to lines.length - 1) { // want to do string searches here, see if line contains s1 and line two lines above also contains s1 //println(lines(i)) } } def recursiveListFiles(f: File): Array[File] = { val these = f.listFiles if (these != null) { for (i = 0 to these.length - 1) { if (these(i).isFile) { processFile(these(i)) } } these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles) } else { Array[File]() } } println(recursiveListFiles(new File(args(0))))

    Read the article

  • mathing string in python

    - by nani
    Write two functions, called countSubStringMatch and countSubStringMatchRecursive that take two arguments, a key string and a target string. These functions iteratively and recursively count the number of instances of the key in the target string. You should complete definitions forthe remaining problems, we are going to explore other substring matching ideas. These problems can be solved with either an iterative function or a recursive one. You are welcome to use either approach, though you may find iterative approaches more intuitive in these cases of matching linear structures

    Read the article

  • how to find if groovy args contains a particular string

    - by groovynoob
    println args println args.size() println args.each{arg-> println arg} println args.class if (args.contains("Hello")) println "Found Hello" when ran give following error: [hello, somethingelse] 2 hello somethingelse [hello, somethingelse] class [Ljava.lang.String; Caught: groovy.lang.MissingMethodException: No signature of method: [Ljava.lang. String;.contains() is applicable for argument types: (java.lang.String) values: [Hello] why can I not do contains?

    Read the article

  • Split string into sentences based on periods

    - by rookie
    Hi all, I have written this piece of code that splits a string and stores it in a string array:- String[] sSentence = sResult.split("[a-z]\.\s+"); However, I've added the [a-z] because I wanted to deal with some of the abbreviation problem. But then my result shows up as so:- Furthermore when Everett tried to instruct them in basic mathematics they proved unresponsiv I see that I loose the pattern specified in the split function. Its okay for me to loose the period, but loosing the last letter of the word disturbs its meaning. Could some one help me with this and in addition also could someone help me with dealing with abbreviations? Like because I split the string based on periods, I do not want to loose the abbreviations. Thanks in advance

    Read the article

  • .Net Round-trip Types

    - by Fujiy
    I making a method that generate a unique string key for some parameters. But the same key if call with same values. I just accept primitive types, string, DateTime, Guid, and Nullable(since I append types together, I can distinguish who is int and who is int?), because I can convert all to string without lost values or precision.(for float and double a use ToString("R"), to DateTime ToString("O")). Exists a easy way to know which types I can transform in strings without conflict? And how do this transform(how I said before, float, double and datetime have specific ways) Thanks

    Read the article

  • Compute hex color code for an arbitrary string

    - by user222164
    Heading Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ? String [] programs = {"XYZ", "TEST1", "TEST2", "TEST3", "SDFSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"}; for(int i = 0; i < programs.length; i++) { System.out.println( programs[i] + " -- " + Integer.toHexString(programs[i].hashCode())); }

    Read the article

  • Simple, Custom Parsing with c++

    - by bradkovach
    Hi! I have been reading SO for some time now, but I truly cannot find any help for my problem. I have a c++ assignment to create an IAS simulator. Here is some sample code... 0 1 a 1 2 b 2 c 3 1 10 begin 11 . load a, subtract b and offset by -1 for jump+ 11 load M(0) 12 sub M(1) 13 sub M(3) 14 halt Using c++, I need to be able to read these lines and store them in a "memory register" class that I already have constructed... For example, the first line would need to store "1 a" in register zero. How can I parse out the number at the line beginning and then store the rest as a string? I have setup storage using a class that is called using mem.set(int, string);. int is the memory location at the beginning of the line and string is the stored instruction.

    Read the article

  • Writing String into a File

    - by Halo
    I'm implementing a WebScript using Alfresco's JavaScript. l'm trying to insert string to a file, but I can't do it. When I write another file's content like: file.properties.content.write(content); It works, and the file's contents are copied into my file. But I can't insert string directly, like: file.properties.content.write("Stuff like that"); it gives an exception. How can I write string into this file?

    Read the article

  • Bit convector : Get byte array from string

    - by nCdy
    When I have a string like "0xd8 0xff 0xe0" I do Text.Split(' ').Select(part => byte.Parse(part, System.Globalization.NumberStyles.HexNumber)).ToArray(); But if I got string like "0xd8ffe0" I don't know what to do ? also I'm able for recommendations how to write byte array as one string.

    Read the article

  • Best way to initialise / clear a string variable cocoa

    - by Spider-Paddy
    I have a routine that parses text via a loop. At the end of each record I need to clear my string variables but I read that someString = @"" actually just points to a new string & causes a memory leak. What is the best way to handle this? Should I rather use mutable string vars and use setString:@"" between iterations?

    Read the article

  • Writing Strings to files in python

    - by Leif Andersen
    I'm getting the following error when trying to write a string to a file in pythion: Traceback (most recent call last): File "export_off.py", line 264, in execute save_off(self.properties.path, context) File "export_off.py", line 244, in save_off primary.write(file) File "export_off.py", line 181, in write variable.write(file) File "export_off.py", line 118, in write file.write(self.value) TypeError: must be bytes or buffer, not str I basically have a string class, which contains a string: class _off_str(object): __slots__ = 'value' def __init__(self, val=""): self.value=val def get_size(self): return SZ_SHORT def write(self,file): file.write(self.value) def __str__(self): return str(self.value) Furthermore, I'm calling that class like this: def write(self, file): for variable in self.variables: variable.write(file) I have no idea what is going on. I've seen other python programs writing strings to files, so why can't this one? Thank you very much for your help.

    Read the article

  • Visual Studio 2010 compile error with std::string?

    - by AJG85
    So this is possibly the strangest thing I've seen recently and was curious how this could happen. The compiler gave me an error saying that std::string is undefined when used as a return type but not when used as a parameter in methods of a class! #pragma once #include <string> #include <vector> // forward declarations class CLocalReference; class CResultSetHandle; class MyClass { public: MyClass() {} ~MyClass {} void Retrieve(const CLocalReference& id, CResultSetHandle& rsh, std::string& item); // this is fine const std::string Retrieve(const CLocalReference& id, CResultSetHandle& rsh); // this fails with std::string is undefined?!?! }; Doing a Rebuild All it still happened I had to choose clean solution and then Rebuild All again after for the universe to realign. While it's resolved for the moment I'd still like to know what could have caused this because I'm at a loss as to why when there should be no conflicts especially when I always use fully qualified names for STL.

    Read the article

  • how to read string part in java

    - by Gandalf StormCrow
    Hello everyone, I have this string : <meis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uri="localhost/naro-nei" onded="flpSW531213" identi="lemenia" id="75" lastStop="bendi" xsi:noNamespaceSchemaLocation="http://localhost/xsd/postat.xsd xsd/postat.xsd"> How can I get lastStop property value in JAVA? This regex worked when tested on http://www.myregexp.com/ But when I try it in java I don't see the matched text, here is how I tried : import java.util.regex.Pattern; import java.util.regex.Matcher; public class SimpleRegexTest { public static void main(String[] args) { String sampleText = <meis xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" uri=\"localhost/naro-nei\" onded=\"flpSW531213\" identi=\"lemenia\" id=\"75\" lastStop=\"bendi\" xsi:noNamespaceSchemaLocation=\"http://localhost/xsd/postat.xsd xsd/postat.xsd\">"; String sampleRegex = "(?<=lastStop=[\"']?)[^\"']*"; Pattern p = Pattern.compile(sampleRegex); Matcher m = p.matcher(sampleText); if (m.find()) { String matchedText = m.group(); System.out.println("matched [" + matchedText + "]"); } else { System.out.println("didn’t match"); } } }

    Read the article

  • How do I deal with connection strings in a Click-Once application?

    - by Pwninstein
    I'm thinking of building a Click-Once application, and am trying to wrap my head around how to handle the whole connection string issue. The problem is the following: I want to use EF to get data directly from each client, thus requiring each client to have a connection string configured (this is not the issue). How do I deal with clients that are not on the same domain as the SQL Server being queried? In other words, if I tried to run my app from home as opposed to from work, what should my connection string look like? Would I need to configure my SQL Server differently to allow this scenario? Thanks in advance!

    Read the article

  • Compare string with all values in array

    - by Hallik
    I am trying to fumble through python, and learn the best way to do things. I have a string where I am doing a compare with another string to see if there is a match: if paid[j].find(d)>=0: #BLAH BLAH If 'd' were an array, what is the most efficient way to see if the string contained in paid[j] has a match to any value in 'd'?

    Read the article

< Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >