Search Results

Search found 4616 results on 185 pages for 'c strings'.

Page 31/185 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Search for a string between two known strings

    - by Flocked
    Hello, I have a String with this content: href="http://www.website.com/" /> [...] [...] I just want to get the central part of the string. How is it possible to get the part between @"href="" and @"" /" Note: Even if it looks like xml-code, it is inside of a NSString.

    Read the article

  • Sort string array by analysing date details in those strings

    - by Jason Evans
    I have a requirement for the project I'm working on right now which is proving a bit tricky for me. Basically I have to sort an array of items based on the Text property of those items: Here are my items: var answers = [], answer1 = { Id: 1, Text: '3-4 weeks ago' }, answer2 = { Id: 2, Text: '1-2 weeks ago' }, answer3 = { Id: 3, Text: '7-8 weeks ago' }, answer4 = { Id: 4, Text: '5-6 weeks ago' }, answer5 = { Id: 5, Text: '1-2 days ago' }, answer6 = { Id: 6, Text: 'More than 1 month ago' }; answers.push(answer1); answers.push(answer2); answers.push(answer3); answers.push(answer4); answers.push(answer5); answers.push(answer6); I need to analyse the Text property of each item so that, after the sorting, the array looks like this: answers[0] = { Id: 6, Text: 'More than 1 month ago' } answers[1] = { Id: 3, Text: '7-8 weeks ago' } answers[2] = { Id: 4, Text: '5-6 weeks ago' } answers[3] = { Id: 1, Text: '3-4 weeks ago' } answers[4] = { Id: 2, Text: '1-2 weeks ago' } answers[5] = { Id: 5, Text: '1-2 days ago' } The logic is that, the furthest away the date, the more high priority it is, so it should appear first in the array. So "1-2 days" is less of a priority then "7-8 weeks". So the logic is that, I need to extract the number values, and then the units (e.g. days, weeks) and somehow sort the array based on those details. Quite honestly I'm finding it very difficult to come up with a solution, and I'd appreciate any help.

    Read the article

  • Java Scanner class reading strings

    - by Max
    I've created a scanner class to read through the text file and get the value what I'm after. Let's assume that I have a text file contains 1 : Fnjiei : ID 7868860 : Age 18 2 : Oipuiieerb : ID 334134 : Age 39 3 : Enekaree : ID 6106274 : Age 31 I'm trying to get a name and id number and age, but everytime I try to run my code it gives me an exception. Here's my code. Any suggestion from java gurus?:) public void readFile(String fileName)throws IOException{ Scanner input = null; input = new Scanner(new BufferedReader(new FileReader(fileName))); try { while (input.hasNextLine()){ int howMany = 3; System.out.println(howMany); String userInput = input.nextLine(); String name = ""; String idS = ""; String ageS = ""; int id; int age; int count=0; for (int j = 0; j <= howMany; j++){ for (int i=0; i < userInput.length(); i++){ if(count < 2){ // for name if(Character.isLetter(userInput.charAt(i))){ name+=userInput.charAt(i); // store the name }else if(userInput.charAt(i)==':'){ count++; i++; } }else if(count == 2){ // for id if(Character.isDigit(userInput.charAt(i))){ idS+=userInput.charAt(i); // store the id } else if(userInput.charAt(i)==':'){ count++; i++; } }else if(count == 3){ // for age if(Character.isDigit(userInput.charAt(i))){ ageS+=userInput.charAt(i); // store the age } } id = Integer.parseInt(idS); // convert id to integer age = Integer.parseInt(ageS); // convert age to integer Fighters newFighters = new Fighters(id, name, age); fighterList.add(newFighters); } userInput = input.nextLine(); } } }finally{ if (input != null){ input.close(); } } } My appology if my mere code begs to be changed.

    Read the article

  • string problems, tuple strings.

    - by suresh
    a tuple representing starting points for the first substring, a tuple representing starting points for the second substring, and the length of the first substring. The function should return a tuple of all members (call it n) of the first tuple for which there is an element in the second tuple n+m+1 = k, where m is the length of the first substring. Complete the definition def constrainedMatchPair(firstMatch,secondMatch,length):

    Read the article

  • Modulation of adding new Strings -> Method calls.

    - by guesswork
    If I have a program that does the following: if(input=='abc'){do x} if(input=='def'){do y} In the future, I may want to add another piece of code like so: if(input=='ghy'){do x} As you can see, I am adding a new 'if' statement for a different conditional BUT using the SAME function X. The code in future has potential to have lots of different IF statements (or switches) all of which are comparing a string vs a string and then performing a function. Considering the future expansion, I was wondering if there is a possible 'neater', 'modular' way of achieving the same results. It's a shame I can't combine the String with a Method call in a hashtable (String, method) in Java. That way I could just store any new procedures inside a hashtable and grab the relevant method for that String. Any ideas? Thank you

    Read the article

  • Help with redirect and query strings

    - by James
    I'm a total novice at mod rewrite so I'll try and present my question as clearly as possible: I'm trying to create a url redirect of the following (static) affiliate url that can append it self to any product links after using a query string: affiliate url: hxxp://clk.affilite.com/fs-bin/click?id=aFb*BBBBBpQ&subid=&offerid=9999.2&type=5&tmpid=9999&RD_PARM1= product url: hxxp:// example.domain.com What I want to achieve is redirecting the affiliate code as below and being able to add dynamic product urls after as the following examples show: rewritten affiliate url: hxxp://domain.com/go affiliate url + product url: hxxp://domain.com/go?=http://example.domain.com redirects to: hxxp://clk.affilite.com/fs-bin/click?id=aFb*BBBBBpQ&subid=&offerid=9999.2&type=5&tmpid=9999&RD_PARM1=http://example.domain.com

    Read the article

  • Reading Excel by OLEDB reads strings as DBNull

    - by Sathish
    I am reading Excel file using OLEDB in Csharp i have shown the sample excel data what i have F1 F2 F3 F4 India 23 44 4 China 4 8 Month 6 USA 45 Neg 4 When i read this data and check in my DataTable i get Null values for "Month 6" and "Neg" where as i can be able get the F1 column correctly... my connection string is as shown Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[XLSource];Extended Properties=Excel 12.0;

    Read the article

  • c++ strings and file input

    - by Dalton Conley
    Ok, its been a while since I've done any file input or string manipulation but what I'm attempting to do is as follows while(infile >> word) { for(int i = 0; i < word.length(); i++) { if(word[i] == '\n') { cout << "Found a new line" << endl; lineNumber++; } if(!isalpha(word[i])) { word.erase(i); } if(islower(word[i])) word[i] = toupper(word[i]); } } Now I assume this is not working because skips the new line character?? If so, whats a better way to do this.

    Read the article

  • Linked List Inserting strings in alphabetical order

    - by user69514
    I have a linked list where each node contains a string and a count. my insert method needs to inset a new node in alphabetical order based on the string. if there is a node with the same string, then i increment the count. the problem is that my method is not inserting in alphabetical order public Node findIsertionPoint(Node head, Node node){ if( head == null) return null; Node curr = head; while( curr != null){ if( curr.getValue().compareTo(node.getValue()) == 0) return curr; else if( curr.getNext() == null || curr.getNext().getValue().compareTo(node.getValue()) > 0) return curr; else curr = curr.getNext(); } return null; } public void insert(Node node){ Node newNode = node; Node insertPoint = this.findIsertionPoint(this.head, node); if( insertPoint == null) this.head = newNode; else{ if( insertPoint.getValue().compareTo(node.getValue()) == 0) insertPoint.getItem().incrementCount(); else{ newNode.setNext(insertPoint.getNext()); insertPoint.setNext(newNode); } } count++; }

    Read the article

  • How to secure connection strings in VS?

    - by salvationishere
    I see several others have posted this question, however, none of the solutions I've tried have fixed this yet. I have a 32-bit XP running VS 2008 and I am trying to encrypt my connection string in my web.config file. But I am getting the error: The configuration section '...' was not found. Failed! The command I give it: C:\Program Files\Microsoft Visual Studio 9.0\VCAspnet_regiis.exe -pe "system.we b/AdventureWorksConnectionString2" -app "/Documents and Settings/Admin/My Docume nts/Visual Studio 2008/Projects/AddFileToSQL2" Also, how does -app map virtual directory? In other words the path above is the directory right below c:. Is this the correct path to use? And AddFileToSQL2 is the name of my project, although it is part of the AddFileToSQL solution. I have this folder web shared with all of the permissions. And the relevant part of my web.config file: <add name="AdventureWorksConnectionString2" connectionString="Data Source=SIDEKICK;Initial Catalog=AdventureWorks;Persist Security Info=true; User ID=AdventureWorks;Password=sqlMagic" providerName="System.Data.SqlClient" />

    Read the article

  • Possible to convert list of #defines into strings (C++)

    - by brandonC
    Suppose I have a list of #defines in a header file for an external library. These #defines represent error codes returned from functions. I want to write a conversion function that can take as an input an error code and return as an output a string literal representing the actual #define name. As an example, if I have #define NO_ERROR 0 #define ONE_KIND_OF_ERROR 1 #define ANOTHER_KIND_OF_ERROR 2 I would like a function to be able to called like int errorCode = doSomeLibraryFunction(); if (errorCode) writeToLog(convertToString(errorCode)); And have convertToString() be able to auto-convert that error code without being a giant switch-case looking like const char* convertToString(int errorCode) { switch (errorCode) { case NO_ERROR: return "NO_ERROR"; case ONE_KIND_OF_ERROR: return "ONE_KIND_OF_ERROR"; ... ... ... I have a feeling that if this is possible, it would be possible using templates and metaprogramming, but that would only work the error codes were actually a type and not a bunch of processor macros. Thanks

    Read the article

  • Can IDL evaluate strings as code?

    - by Carthage
    Is there any functionality in IDL that will allow it to evaluate a a string as code? Or, failing that, is there a nice, dynamic way of including /KEYWORD in functions? For example, if I wanted to ask them for what type of map projection the user wants, is there a way to do it nicely, without large if/case statements for the /Projection_Type keyword it needs? With even a small number of user options, the combinations would cause if/case statements to get out of hand very quickly to handle all the possible options.

    Read the article

  • Caching images with different query strings (S3 signed urls)

    - by Brendan Long
    I'm trying to figure out if I can get browsers to cache images with signed urls. What I want is to generate a new signed url for every request (same image, but with an updated signature), but have the browser not re-download it every time. So, assuming the cache-related headers are set correctly, and all of the URL is the same except for the query string, is there any way to make the browser cache it? The urls would look something like: http://example.s3.amazonaws.com/magic.jpg?WSAccessKeyId=stuff&Signature=stuff&Expires=1276297463 http://example.s3.amazonaws.com/magic.jpg?WSAccessKeyId=stuff&Signature=stuff&Expires=1276297500 We plan to set the e-tags to be an md5sum, so will it at least figure out it's the same image at that point? My other option is to keep track of when last gave out a url, then start giving out new ones slightly before the old ones expire, but I'd prefer not to deal with session info.

    Read the article

  • Assigning two strings together getting Access Read Violation

    - by Jay Bell
    I am trying to pass a string to a class mutator and set the private member to that string here is the code that is sending the string void parseTradePairs(Exchange::Currency *curr, std::string *response, int begin, int exit) { int start; int end; string temp; string dataResponse; CURL *tempCurl; initializeCurl(tempCurl); int location = response->find("marketid", begin); if(location <= exit) { start = location + 11; begin = response->find("label", start); end = begin - start - 3; findStrings(start, end, temp, response); getMarketInfo(tempCurl, temp, dataResponse); curr->_coin->setExch(temp); // here is the line of code that is sending the string dataResponse >> *(curr->_coin); curr->_next = new Exchange::Currency(curr, curr->_position + 1); parseTradePairs(curr->_next, response, begin, exit); } } and here is the mutator within the coin class that is receiving the string and assigning it to _exch void Coin::setExch(string exch) { _exch = exch; } I have stepped through it and made sure that exch has the string in it. "105" but soon as it hits _exch = exch; I get the reading violation. I tried passing as pointer as well. I do not believe it should go out of scope. and the string variable in the class is initialized to zero in the default constructor but again that should matter unless I am trying to read from it instead of writing to it. /* defualt constructor */ Coin::Coin() { _id = ""; _label = ""; _code= ""; _name = ""; _marketCoin = ""; _volume = 0; _last = 0; _exch = ""; } Exchange::Exchange(std::string str) { _exch = str; _currencies = new Currency; std::string pair; std::string response; CURL *curl; initializeCurl(curl); getTradePairs(curl, response); int exit = response.find_last_of("marketid"); parseTradePairs(_currencies, &response, 0, exit); } int main(void) { CURL *curl; string str; string id; Coin coin1; initializeCurl(curl); Exchange ex("cryptsy"); curl_easy_cleanup(curl); system("pause"); return 0; } class Exchange { public: typedef struct Currency { Currency(Coin *coin, Currency *next, Currency *prev, int position) : _coin(coin), _next(next), _prev(prev), _position(position) {} Currency(Currency *prev, int position) : _prev(prev), _position(position), _next(NULL), _coin(&Coin()){} Currency() : _next(NULL), _prev(NULL), _position(0) {} Coin *_coin; Currency *_next; Currency *_prev; int _position; }; /* constructor and destructor */ Exchange(); Exchange(std::string str); ~Exchange(); /* Assignment operator */ Exchange& operator =(const Exchange& copyExchange); /* Parse Cryptsy Pairs */ friend void parseTradePairs(Currency *curr, std::string *response, int begin, int exit); private: std::string _exch; Currency *_currencies; }; here is what i changed it to to fix it. typedef struct Currency { Currency(Coin *coin, Currency *next, Currency *prev, int position) : _coin(coin), _next(next), _prev(prev), _position(position) {} Currency(Currency *prev, int position) : _prev(prev), _position(position), _next(NULL), _coin(&Coin()){} Currency() { _next = NULL; _prev = NULL; _position = 0; _coin = new Coin(); } Coin *_coin; Currency *_next; Currency *_prev; int _position; };

    Read the article

  • Dealing with large number of text strings

    - by Fadrian
    My project when it is running, will collect a large number of string text block (about 20K and largest I have seen is about 200K of them) in short span of time and store them in a relational database. Each of the string text is relatively small and the average would be about 15 short lines (about 300 characters). The current implementation is in C# (VS2008), .NET 3.5 and backend DBMS is Ms. SQL Server 2005 Performance and storage are both important concern of the project, but the priority will be performance first, then storage. I am looking for answers to these: Should I compress the text before storing them in DB? or let SQL Server worry about compacting the storage? Do you know what will be the best compression algorithm/library to use for this context that gives me the best performance? Currently I just use the standard GZip in .NET framework Do you know any best practices to deal with this? I welcome outside the box suggestions as long as it is implementable in .NET framework? (it is a big project and this requirements is only a small part of it) EDITED: I will keep adding to this to clarify points raised I don't need text indexing or searching on these text. I just need to be able to retrieve them in later stage for display as a text block using its primary key. I have a working solution implemented as above and SQL Server has no issue at all handling it. This program will run quite often and need to work with large data context so you can imagine the size will grow very rapidly hence every optimization I can do will help.

    Read the article

  • [C#] RegEx search for two pattern strings and cut what's between

    - by gsharp
    I'm trying to write a little SQL Helper. I have a query like this stored in a string: DECLARE @V1 INT --ignore DECLARE @V11 INT DECLARE @V12 INT --endignore DECLARE @V2 INT --ignore SELECT * FROM SampleTable INNER JOIN AnotherSampleTable ...... --endignore SELECT * From Employee ORDER BY LastName My helper method should cut everything what's between --ignore and --endignore The result string should look like: DECLARE @V1 INT DECLARE @V2 INT SELECT * From Employee ORDER BY LastName How can achieve my result with RegEx?

    Read the article

  • Sorting an array of strings in reverse alphabetical order in Java

    - by Quacky
    I've been tasked with turning this code into a reverse sort, but for the life of me cannot figure out how to do it. These are my sort, findlargest and swap methods. I have a feeling I am missing something glaringly obvious here, any help would be really appreciated. public static void sort(String[] arr) { for (int pass = 1; pass < arr.length; pass++) { int largestPos = findLargest(arr, arr.length - pass); if (largestPos != arr.length - pass) { swap(arr, largestPos, arr.length - pass); } } } public static int findLargest(String[] arr, int num) { int largestPos = 0; for (int i = 1; i <= num; i++) { if (arr[i].compareToIgnoreCase(arr[largestPos]) > 0) { largestPos = i; } } return largestPos; } public static void swap(String[] arr, int first, int second) { String temp = arr[first]; arr[first] = arr[second]; arr[second] = temp; } }

    Read the article

  • maching strings

    - by kiran
    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 for def countSubStringMatch(target,key): and def countSubStringMatchRecursive (target, key): For the 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

  • Find all substrings between two strings

    - by Orsol
    I need to get all substrings from string. For ex: StringParser.GetSubstrings("[start]aaaaaa[end] wwwww [start]cccccc[end]", "[start]", "[end]"); that returns 2 string "aaaaaa" and "cccccc" Suppose we have only one level of nesting. Not sure about regexp, but I think it will be userful.

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >