Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 137/1413 | < Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >

  • Bash, Concatenating 2 strings to reference a 3rd variable

    - by Im Fine
    I have a bash script I am having some issues with concatenating 2 variables to call a 3rd. Here is a simplification of the script, but the syntax is eluding me after reading the docs. server_list_all="server1 server2 server3"; var1 = "server"; var2 = "all"; echo $(($var1_list_$var2)); This is about as close as I get to the right answer, it acknowledges the string and tosses an error on tokenization. syntax error in expression (error token is "server1 server2 server3.... Not really seeing anything in the docs for this, but it should be doable. EDIT: Cleaned up a bit

    Read the article

  • parse unformatted string into dictionary with python

    - by user553131
    I have following string. DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) Key: a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO I need to create dictionary so it would be like { "DATE": "12242010", "Key Type": "Nod32 Anti-Vir (30d trial)", "Key": "a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO" } The problem is that string is unformatted DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) there is no space after Date before Key Type also it would be nice to have some validation for Key, eg if there are 5 chars in each box of key and number of boxes I am a beginner in python and moreover in regular expressions. Thanks a lot.

    Read the article

  • construct a unique number for a string in java

    - by praveen
    We have a requirement of reading/writing more than 10 million strings into a file. Also we do not want duplicates in the file. Since the strings would be flushed to a file as soon as they are read we are not maintaining it in memory. We cannot use hashcode because of collisions in the hash code due to which we might miss a string as duplicate. Two other approaches i found in my googling: 1.Use a message digest algorithm like MD5 - but it might be too costly to calculate and store. 2.Use a checksum algorithm. [i am not sure if this produces a unique key for a string- can someone please confirm] Is there any other approach avaiable. Thanks.

    Read the article

  • Is there a circular hash function?

    - by Phil H
    Thinking about this question on testing string rotation, I wondered: Is there was such thing as a circular/cyclic hash function? E.g. h(abcdef) = h(bcdefa) = h(cdefab) etc Uses for this include scalable algorithms which can check n strings against each other to see where some are rotations of others. I suppose the essence of the hash is to extract information which is order-specific but not position-specific. Maybe something that finds a deterministic 'first position', rotates to it and hashes the result? It all seems plausible, but slightly beyond my grasp at the moment; it must be out there already...

    Read the article

  • xcode - EXEC_BAD_ACCESS when concatenting a large string.

    - by Frames1984
    I'm getting a EXEC_BAD_ACCESS when concatenting a large string. I've read from a feed and to create my webview i build up my string like: NSString *pageData = @"<h1>header</h1>"; pageData = [pageData stringByAppendingFormat@"<p>"]; pageData = [pageData stringByAppendingFormat@"self.bodyText"]; pageData = [pageData stringByAppendingFormat@"</p>"]; etc problem i've got is self.bodytext is 21,089 charachers with spaces when I do a count on word. Is there a better method for doing this? Thank

    Read the article

  • how to remove security settings from a connection string in vb.net

    - by teju
    hi i am trying to add data to the database that was created by some one but when am trying to insert or delete or update the exception is raising and entire project is not working properly and the error i am facing is "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" so now what should i do to resolve this error and my connection string is written as Dim CON As New SqlConnection("Integrated Security=SSPI; Persist Security Info=False;Initial Catalog=DIGITALGAMES; Data Source=TEJUS-PC\SQLEXPRESS") is there any problem with my connection string ??

    Read the article

  • How to compare string with const char*?

    - by arzeth
    #include <stdlib.h> #include <stdio.h> #include <iostream> #include <string.h> using namespace std; int main() { string cmd; while(strcmp(cmd.c_str(),"exit")==0 && strcmp(cmd.c_str(),"\exit")==0) { cin>>cmd; cout<<cmd; } return 0; } I am stuck.

    Read the article

  • How to test if Scala combinator parser matches a string

    - by W.P. McNeill
    I have a Scala combinator parser that handles comma-delimited lists of decimal numbers. object NumberListParser extends RegexParsers { def number: Parser[Double] = """\d+(\.\d*)?""".r ^^ (_.toDouble) def numbers: Parser[List[Double]] = rep1sep(number, ",") def itMatches(s: String): Boolean = parseAll(numbers, s) match { case _: Success[_] => true case _ => false } } The itMatches function returns true when given a string that matches the pattern. For example: NumberListParser.itMatches("12.4,3.141") // returns true NumberListParser.itMatches("bogus") // returns false Is there a more terse way to do this? I couldn't find one in the documentation, but my function sees a bit verbose, so I wonder if I'm overlooking something.

    Read the article

  • Automate Monitor string in different log files

    - by EVIA
    I have few log files in different servers and I want to check output in the end of those log files for e.g . success: 4000 failed: 200 These logs files are getting generated daily and I have to keep track of these numbers. If there is any way I can automate this option instead of going and checking these files and wasting so much of my time. I want to create some kind of script like Go to \serverA\C$\log_07_02_2012.txt and check this line Go to \serverB\C$\log_07_02_2012.txt and check some other line. .... and it should give me output from all of these...

    Read the article

  • convert char[] to String in btrace

    - by usovmv
    Hi folks! I'm profiling application with btrace (https://btrace.dev.java.net) and faced with limitation. I try to get a name of current java.lang.Thread. Normaly you can call getName() but it's forbidden in btrace-scripts (any calls exception BTraceUtils). Is there any idea how to get String from char[]. The original task is check if name of thread contains sub-string and only then log out tracing info (reducing output). thanks, Max.

    Read the article

  • Conditional Branching Issues

    - by Zack
    Here is the code: def main_menu print_main_menu user_selected = gets.chomp if user_selected.downcase == "no" main_menu elsif user_selected == "1" || "2" || "3" || "4" || "5" || "6" || "7" user_selected = user_selected.to_i call_option(user_selected) else main_menu end end This code uses calls to allow a user to make a selection from a main menu. Depending on the input, be it a certain number, a certain word, or something else, the respective method is called (in the case of a valid input) or the main menu is printed again (in the case of an invalid input or "no"). My questions are twofold. 1) Is there an efficient way to get rid of the literal string error that appears as a result of this redundant or statement on the elsif line? (the code itself works fine, but this error appears and is frustrating). 2) When an alternate/unspecified input is made by the user, the else branch doesn't execute and main_method doesn't start over. I have no idea why this is happening. Is there something I'm missing here? Thanks

    Read the article

  • Remove \r from a string in C++

    - by Werner
    Hi, in a C++ program, there is a point when it reads a string like: "NONAME_1_1\r" the \r is causing me trouble. I guess it prints or adds something like "^M". Is it right? Anyway it casues me problem, and I want to get rid of it. I can not modify the input. I wonder how could I at this point, using C++, and in the easiest way, to remove \r for this string. I know how to do it on bash but no clue on C++. Thanks.

    Read the article

  • String path validation

    - by CMAñora
    I have here a string(an input from the user) for a file path. I checked the string so that it will qualify the criteria: check for invalid characters for a file path will not accept absolute path (\Sample\text.txt) I have tried catching the invalid characters in catch clause. It work except for '\'. It will accept 'C:\\Sample\text.txt' which is an invalid file path. The following examples should be invalid paths: :\text.txt :text.txt \:text.txt \text.txt C:\\\text.txt I have been through similar questions posted here but none of them seemed to solve my issue. What would be the best way to do such check?

    Read the article

  • Using traversal by pointer to check whether a string is repeated

    - by Bob John
    bool repeat_char(char *s, int n); //R: s is a C-string of at least n non-NUL characters and n > 0 //E: returns true if the first n characters are fully repeated throughout the string s, false // otherwise. I'm having trouble implementing this function using traversal by pointer. I was thinking that I could extract the first n characters from s, then use that in a comparison with s, but I'm not sure how I could do that. If I'm traversing through s one character at a time, how can I check that it matches a block of text, such as the first n characters of s? Thanks!

    Read the article

  • how to generate XML (in String representation) in java

    - by flyingfromchina
    I have defined a java class, but only need to output some of the fields of this class into an XML. The returned type must be a String. I first opted for the easiest way using a StringBuffer. However, when I tried to process the output String represenation, it failed. I think it is mostly likely because there are some characters that are not encoded in the UTF-8 in the input. Could someone tell me what is the best way to handle this? Thanks.

    Read the article

  • C# Deserializing to a dictionary<string, Object>

    - by lovecraft
    I'm writing a C#/VB application to connect to a database and do stuff with the data. I was given this code to take a serialized byte array and deserialized it, which is then written to a Dictionary The line of code is: Dictionary<string, Object> DictionaryEmployee = (Dictionary<string, Object> Deserializer(byteArrayEmp)); The errors I'm getting are exceedingly unhelpful. "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement" if I mouse over Object and "Using the generic type 'System.Collections.Generic.Dictionary' requires 2 type arguments if I mouse over Dictionary.

    Read the article

  • extract two parts of a string using regex in php

    - by Jubair
    Ok so I have this string: &lt;img src=images/imagename.gif alt='descriptive text here'&gt; and I am trying to split it up into the following two strings (array of two strings, what ever, just broken up). imagename.gif descriptive text here Note yes, its' actually the & lt; and not < same with the closing on the string. I know regex is the answer, but not the best at regext to know to pull it off in php.

    Read the article

  • Android search list, String

    - by NightSky
    Hey guys what is the best way to search through my list of objects, they return a few strings, last name and first name for example. Here how i'm currently searching but my search needs to match the entire string which I don't want. The search needs it to match part of the string like our contacts list on our phone and ignore the case. if (searchQ.equalsIgnoreCase(child.first_name)) { addChildToList(child); } Ive tried contains and starts with for example, they did not work. Whats going on? Thanks! Cheers!

    Read the article

  • Code Trivia #4

    - by João Angelo
    Got the inspiration for this one in a recent stackoverflow question. What should the following code output and why? class Program { class Author { public string FirstName { get; set; } public string LastName { get; set; } public override string ToString() { return LastName + ", " + FirstName; } } static void Main() { Author[] authors = new[] { new Author { FirstName = "John", LastName = "Doe" }, new Author { FirstName = "Jane", LastName="Doe" } }; var line1 = String.Format("Authors: {0} and {1}", authors); Console.WriteLine(line1); string[] serial = new string[] { "AG27H", "6GHW9" }; var line2 = String.Format("Serial: {0}-{1}", serial); Console.WriteLine(line2); int[] version = new int[] { 1, 0 }; var line3 = String.Format("Version: {0}.{1}", version); Console.WriteLine(line3); } } Update: The code will print the first two lines // Authors: Doe, John and Doe, Jane // Serial: AG27H-6GHW9 and then throw an exception on the third call to String.Format because array covariance is not supported in value types. Given this the third call of String.Format will not resolve to String.Format(string, params object[]), like the previous two, but to String.Format(string, object) which fails to provide the second argument for the specified format and will then cause the exception.

    Read the article

  • IIS 7 can't connect to SQLServer 2008

    - by Nicolas Cadilhac
    Sorry if this is the most seen question on the web, but this is my turn. I am trying to publish my asp.net mvc app on IIS 7 under MS Sql Server 2008. I am on a Windows Server 2008 virtual machine. I get the following classical error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Under SQLServer, Allow remote connections is checked. My connection string is: Data Source=.\MSSQLSERVER;Initial Catalog=mydbname;User Id=sa;Password=mypassword I also tried with no username/password and "Integrated Security=true". There is only one instance of SQLServer installed. I tried to access my web page locally and remotely. There is no active firewall on the virtual machine. Thx for your help.

    Read the article

  • Parsing a file in C

    - by sfactor
    I need parse through a file and do some processing into it. The file is a text file and the data is a variable length data of the form "PP1004181350D001002003..........". So there will be timestamps if there is PP so 1004181350 is 2010-04-08 13:50. The ones where there are D are the data points that are three separate data each three digits long, so D001002003 has three coordonates of 001, 002 and 003. Now I need to parse this data from a file for which I need to store each timestamp into a array and the corresponding datas into arrays that has as many rows as the number of data and three rows for each co-ordinate. The end array might be like TimeStamp[1] = "135000", low[1] = "001", medium[1] = "002", high[1] = "003" TimeStamp[2] = "135015", low[2] = "010", medium[2] = "012", high[2] = "013" TimeStamp[3] = "135030", low[3] = "051", medium[3] = "052", high[3] = "043" .... The question is how do I go about doing this in C? How do I go through this string looking for these patterns? Note: Here the seconds value in timestamp is added on our own as it is known at each data comes after 15 seconds.

    Read the article

  • How bad is code using std::basic_string<t> as a contiguous buffer?

    - by BillyONeal
    I know technically the std::basic_string template is not required to have contiguous memory. However, I'm curious how many implementations exist for modern compilers that actually take advantage of this freedom. For example, if one wants code like the following it seems silly to allocate a vector just to turn around instantly and return it as a string: DWORD valueLength = 0; DWORD type; LONG errorCheck = RegQueryValueExW( hWin32, value.c_str(), NULL, &type, NULL, &valueLength); if (errorCheck != ERROR_SUCCESS) WindowsApiException::Throw(errorCheck); else if (valueLength == 0) return std::wstring(); std::wstring buffer; do { buffer.resize(valueLength/sizeof(wchar_t)); errorCheck = RegQueryValueExW( hWin32, value.c_str(), NULL, &type, &buffer[0], &valueLength); } while (errorCheck == ERROR_MORE_DATA); if (errorCheck != ERROR_SUCCESS) WindowsApiException::Throw(errorCheck); return buffer; I know code like this might slightly reduce portability because it implies that std::wstring is contiguous -- but I'm wondering just how unportable that makes this code. Put another way, how may compilers actually take advantage of the freedom having noncontiguous memory allows? Oh: And of course given what the code's doing this only matters for Windows compilers.

    Read the article

  • Unicode strings in my C# App are shown with question marks

    - by mrbamboo
    Hi, I have a header file in C++/CLR project, which contains some strings in different languages. arabic, english, german, chinese, french, japanese etc... I have a second project written in C#. Here I access the strings stored in the header file of the C++/CLR project. The encoding of the header file is Unicode - Codepage 1200 or UTF-8. the visual studio editor is able to display the strings correctly. At runtime I access these strings and assign them into a local String variable. Here I recognized that many strings are not shown correctly. Doesn't matter if I assign them or not. Accessing the original place (while debugging) shows me all the foreign strings with question marks. Especially chinese, just question marks. Example : "So?e St?ange ?ext in Ch?n?se" (This is not the best example, I know) What is the problem? I read that C# is by default UTF-16, My header file containing the strings is UTF-16 or UTF-8. I must be able to handle strings in different languages. What am I doing wrong?

    Read the article

  • Bitap algorithm in Java [closed]

    - by davit-datuashvili
    The following is the bitap algorithm according to Wikipedia. Can someone translate this to Java? #include <string.h> #include <limits.h> const char *bitap_bitwise_search(const char *text, const char *pattern) { int m = strlen(pattern); unsigned long R; unsigned long pattern_mask[CHAR_MAX+1]; int i; if (pattern[0] == '\0') return text; if (m > 31) return "The pattern is too long!"; /* Initialize the bit array R */ R = ~1; /* Initialize the pattern bitmasks */ for (i=0; i <= CHAR_MAX; ++i) pattern_mask[i] = ~0; for (i=0; i < m; ++i) pattern_mask[pattern[i]] &= ~(1UL << i); for (i=0; text[i] != '\0'; ++i) { /* Update the bit array */ R |= pattern_mask[text[i]]; R <<= 1; if (0 == (R & (1UL << m))) return (text + i - m) + 1; } return NULL; }

    Read the article

< Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >