Search Results

Search found 35200 results on 1408 pages for 'string'.

Page 6/1408 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • C# collection/string .Contains vs collection/string.IndexOf

    - by Daniel
    Is there a reason to use .Contains on a string/list instead of .IndexOf? Most code that I would write using .Contains would shortly after need the index of the item and therefore would have to do both statements. But why not both in one? if ((index = blah.IndexOf(something) = 0) // i know that Contains is true and i also have the index

    Read the article

  • Finding substring of a word found in joining a string from another string

    - by 2er0
    Given a list of words, L, that are all the same length, and a string, S, find the starting position of the substring of S that is a concatenation of each word in L exactly once and without any intervening characters. This substring will occur exactly once in S. Example: L: "fooo", "barr", "wing", "ding", "wing" S: "lingmindraboofooowingdingbarrwingmonkeypoundcake" Word found in joining L and also found in S: "fooowingdingbarrwing" Answer: 13 L: "mon", "key" S: "monkey Word found in joining L and also found in S: "monkey Answer: 0 L: "a", "b", "c", "d", "e" S: "abcdfecdba" Word found in joining L and also found in S: "ecdba Answer: 5

    Read the article

  • Remove characters after specific character in string, then remove substring?

    - by sah302
    I feel kind of dumb posting this when this seems kind of simple and there are tons of questions on strings/characters/regex, but I couldn't find quite what I needed (except in another language: http://stackoverflow.com/questions/2176544/remove-all-text-after-certain-point). I've got the following code: [Test] public void stringManipulation() { String filename = "testpage.aspx"; String currentFullUrl = "http://localhost:2000/somefolder/myrep/test.aspx?q=qvalue"; String fullUrlWithoutQueryString = currentFullUrl.Replace("?.*", ""); String urlWithoutPageName = fullUrlWithoutQueryString.Remove(fullUrlWithoutQueryString.Length - filename.Length); String expected = "http://localhost:2000/somefolder/myrep/"; String actual = urlWithoutPageName; Assert.AreEqual(expected, actual); } I tried the solution in the question above (hoping the syntax would be the same!) but nope. I want to first remove the queryString which could be any variable length, then remove the page name, which again could be any length. How can I get the remove the query string from the full URL such that this test passes?

    Read the article

  • How to extract specific variables from a string?

    - by David
    Hi, let's say i have the following: $vars="name=david&age=26&sport=soccer&birth=1984"; I want to turn this into real php variables but not everything. By example, the functions that i need : $thename=getvar($vars,"name"); $theage=getvar($vars,"age"); $newvars=cleanup($vars,"name,age"); // Output $vars="name=david&age=26" How can i get only the variables that i need . And how i clean up the $vars from the other variables if possible? Thanks

    Read the article

  • String formatting error

    - by wrongusername
    Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: cannot import name format What am I doing wrong here?

    Read the article

  • How to replace round bracket tag in javascript string

    - by tomaszs
    I have trouble with changing round bracket tag in Javascript. I try to do this: var K = 1; var Text = "This a value for letter K: {ValueOfLetterK}"; Text = Text.replace("{ValueOfLetterK}", K); and after that I get: Text = "This a value for letter K: {ValueOfLetterK}" What can be done to make this work? When I remove round brackets it works fine.

    Read the article

  • Problem with Replacing special characters in a string

    - by Hossein
    Hi, I am trying to feed some text to a special pupose parser. The problem with this parser is that it is sensitive to ()[] characters and in my sentence in the text have quite a lot of these characters. The manual for the parser suggests that all the ()[] get replaced with \( \) \[ \]. So using str.replace i am using to attach \ to all of those charcaters. I use the code below: a = 'abcdef(1234)' a.replace('(','\(') however i get this as my output: 'abcdef\\(1234)' What is wrong with my code? can anyone provide me a solution to solve this for these characters?

    Read the article

  • Replacing substring in a string

    - by user177785
    I am uploading a image file to the server. Now after uploading the file to the server I need to rename the file with an id, but the extension of the file should be retained. Eg: if I upload the file image1.png then my server script should retain the extension .png. But I need to change the substring to some other substring (primary key of db). image1.png should be renamed to 123.png image2.jpg should be renamed to somevalue.jpg The image can be of any extension like .png, .jpg, .jpeg etc. I want to rename then in such a way that the image/file extension should be retained.

    Read the article

  • String to array or Array to string tips on formats, etc

    - by user316841
    hi, first of all thanks for taking your time! I'm a junior Dev, working with PHP + mysql. My issue: I'm saving data from a form to my database. From this form, there's only need to save the contacts: Name, phone number, address. But, it would be nice to have a small reference to the user answers. Let's say for each question we've got a value betwee 1 and 4. Since there's no need to create a table just for it, because what's needed is just the personal contacts. I'm thinking of recording each question/answer, as a letter and its correspondent value. Example (A2, B1, C5, D3, etc). My question is: Is there a format I could afterwards, handle easily ? Convert to array (string to array) in case the client change ideas, and ask this data, placed in table columns ? Just to prevent this situation! Example, From (A2, B1, C5 ) to array( "A" = "1", "B" = "1", "C" = "5" ) For now I guess, Regex is the answer, but it's allways hard to figure it out and I'm allways getting in troubles =) Thanks!

    Read the article

  • SQL SERVER – Find First Non-Numeric Character from String

    - by pinaldave
    It is fun when you have to deal with simple problems and there are no out of the box solution. I am sure there are many cases when we needed the first non-numeric character from the string but there is no function available to identify that right away. Here is the quick script I wrote down using PATINDEX. The function PATINDEX exists for quite a long time in SQL Server but I hardly see it being used. Well, at least I use it and I am comfortable using it. Here is a simple script which I use when I have to identify first non-numeric character. -- How to find first non numberic character USE tempdb GO CREATE TABLE MyTable (ID INT, Col1 VARCHAR(100)) GO INSERT INTO MyTable (ID, Col1) SELECT 1, '1one' UNION ALL SELECT 2, '11eleven' UNION ALL SELECT 3, '2two' UNION ALL SELECT 4, '22twentytwo' UNION ALL SELECT 5, '111oneeleven' GO -- Use of PATINDEX SELECT PATINDEX('%[^0-9]%',Col1) 'Position of NonNumeric Character', SUBSTRING(Col1,PATINDEX('%[^0-9]%',Col1),1) 'NonNumeric Character', Col1 'Original Character' FROM MyTable GO DROP TABLE MyTable GO Here is the resultset: Where do I use in the real world – well there are lots of examples. In one of the future blog posts I will cover that as well. Meanwhile, do you have any better way to achieve the same. Do share it here. I will write a follow up blog post with due credit to you. Reference : Pinal Dave (http://blog.SQLAuthority.com) Filed under: PostADay, SQL, SQL Authority, SQL Function, SQL Query, SQL Server, SQL String, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • String.valueOf(int value) gives error [closed]

    - by Davidrd91
    I am trying to convert an int into a String so that I can put the String values into an SQLite Cursor. I've tried multiple syntax and methods but none seem to work for me. The Error occurs in MangaItemDB() while trying to convert any Int types aswell as the boolean. I've looked through several articles like this one but none works for me. Here's my code: public class MangaItem { private int _id; private String mangaName; private String mangaLink; private static String mangaAlpha; private static int mangaCount; private static int alphaCount; private boolean mangaComplete = false; public MangaItem MangaItemDB(int id, String mangaName, String mangaLink, String mangaAlpha, String mangaCount, String alphaCount, String mangaComplete) { MangaItem MangaItemDB = new MangaItem(); MangaItemDB._id = id; MangaItemDB.mangaName = mangaName; MangaItemDB.mangaLink = mangaLink; MangaItemDB.mangaAlpha = mangaAlpha; MangaItemDB.mangaCount = String.valueOf(int mangaCount); MangaItemDB.alphaCount = Integer.toString(getAlphaCount()); MangaItemDB.mangaComplete = String.valueOf(getMangaComplete()); return MangaItemDB; } public void incrementMangaCount() { mangaCount++; } public int getMangaCount() { return mangaCount; } public void incrementAlphaCount() { alphaCount++; } public int getAlphaCount() { return alphaCount; } public boolean setMangaComplete(boolean mangaComplete) { return true; } public boolean getMangaComplete() { return mangaComplete; } /** * @return the mangaName */ public String getMangaName() { return mangaName; } /** * @param mangaName the mangaName to set */ public void setMangaName(String mangaName) { this.mangaName = mangaName; } /** * @return the mangaLink */ public String getMangaLink() { return mangaLink; } /** * @param mangaLink the mangaLink to set */ public void setMangaLink(String mangaLink) { this.mangaLink = mangaLink; } /** * @return the mangaAlpha */ public String getMangaAlpha() { return mangaAlpha; } /** * @param mangaAlpha the mangaAlpha to set */ public void setMangaAlpha(String mangaAlpha) { this.mangaAlpha = mangaAlpha; } /** * @return the _id */ public int get_id() { return _id; } /** * @param _id the _id to set */ public void set_id(int _id) { this._id = _id; } } The lines : MangaItemDB.mangaCount = String.valueOf(mangaCount); MangaItemDB.alphaCount = Integer.toString(getAlphaCount()); MangaItemDB.mangaComplete = String.valueOf(getMangaComplete()); all give "Type mismatch: cannot convert from String to Int"

    Read the article

  • String Length Evaluating Incorrectly

    - by Justin R.
    My coworker and I are debugging an issue in a WCF service he's working on where a string's length isn't being evaluated correctly. He is running this method to unit test a method in his WCF service: // Unit test method public void RemoveAppGroupTest() { string addGroup = "TestGroup"; string status = string.Empty; string message = string.Empty; appActiveDirectoryServicesClient.RemoveAppGroup("AOD", addGroup, ref status, ref message); } // Inside the WCF service [OperationBehavior(Impersonation = ImpersonationOption.Required)] public void RemoveAppGroup(string AppName, string GroupName, ref string Status, ref string Message) { string accessOnDemandDomain = "MyDomain"; RemoveAppGroupFromDomain(AppName, accessOnDemandDomain, GroupName, ref Status, ref Message); } public AppActiveDirectoryDomain(string AppName, string DomainName) { if (string.IsNullOrEmpty(AppName)) { throw new ArgumentNullException("AppName", "You must specify an application name"); } } We tried to step into the .NET source code to see what value string.IsNullOrEmpty was receiving, but the IDE printed this message when we attempted to evaluate the variable: 'Cannot obtain value of local or argument 'value' as it is not available at this instruction pointer, possibly because it has been optimized away.' (None of the projects involved have optimizations enabled). So, we decided to try explicitly setting the value of the variable inside the method itself, immediately before the length check -- but that didn't help. // Lets try this again. public AppActiveDirectoryDomain(string AppName, string DomainName) { // Explicitly set the value for testing purposes. AppName = "AOD"; if (AppName == null) { throw new ArgumentNullException("AppName", "You must specify an application name"); } if (AppName.Length == 0) { // This exception gets thrown, even though it obviously isn't a zero length string. throw new ArgumentNullException("AppName", "You must specify an application name"); } } We're really pulling our hair out on this one. Has anyone else experienced behavior like this? Any tips on debugging it?

    Read the article

  • PHP mySQL - replace some string inside string

    - by apis17
    i want to replace ALL comma , into ,<space> in all address table in my mysql table. For example, +----------------+----------------+ | Name | Address | +----------------+----------------+ | Someone name | A1,Street Name | +----------------+----------------+ Into +----------------+----------------+ | Name | Address | +----------------+----------------+ | Someone name | A1, Street Name| +----------------+----------------+ Thanks in advance.

    Read the article

  • Interning strings in Java

    - by Tiny
    The following segment of code interns a string. String str1="my"; String str2="string"; String concat1=str1+str2; concat1.intern(); System.out.println(concat1=="mystring"); The expression concat1=="mystring" returns true because concat1 has been interned. If the given string mystring is changed to string as shown in the following snippet. String str11="str"; String str12="ing"; String concat11=str11+str12; concat11.intern(); System.out.println(concat11=="string"); The comparison expression concat11=="string" returns false. The string held by concat11 doesn't seem to be interned. What am I overlooking here? I have tested on Java 7, update 11.

    Read the article

  • Add string to another string

    - by daemonfire300
    Hi there, I currently encountered a problem: I want to handle adding strings to other strings very efficiently, so I looked up many methods and techniques, and I figured the "fastest" method. But I quite can not understand how it actually works: def method6(): return ''.join([`num` for num in xrange(loop_count)]) From source (Method 6) Especially the ([numfor num in xrange(loop_count)]) confused me totally.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >