Search Results

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

Page 15/1408 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • javascript - shorten string to fit into a certain # of lines

    - by Mala
    Hi I have a string that must fit into a box, and must be at most 3 lines long. To shorten it, I plan to truncate it and end it with '...'. I could shorten it to a certain # of characters but if i make it look good with "wwwwwwwww [...] wwww" it won't look right with "iiiiiiiiiii [...] iiii". Is there some way I can shorten it by how much space the string would take up, as opposed to how many characters there are in a string without using a fixed-width font? Mala ps. Please no "simply create an image of '...' and overlay it over the end of the line" hacks or similar - I actually want to shorten the string to the appropriate length

    Read the article

  • javascript/php - shorten string to fit into a certain # of lines

    - by Mala
    Hi I have a string that must fit into a box, and must be at most 3 lines long. To shorten it, I plan to truncate it and end it with '...'. I could shorten it to a certain # of characters but if i make it look good with "wwwwwwwww [...] wwww" it won't look right with "iiiiiiiiiii [...] iiii". Is there some way I can shorten it by how much space the string would take up, as opposed to how many characters there are in a string without using a fixed-width font? Ideally I'd like to do this server-side (php) but recognize that actual character width stuff is far more likely to be feasible client-side (JS / jQuery) Mala ps. Please no "simply create an image of '...' and overlay it over the end of the line" hacks or similar - I actually want to shorten the string to the appropriate length

    Read the article

  • String parsing help

    - by Click Upvote
    I have a string like the following: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; I would like to split this string into an array contanining the text found between the <paragraph></paragraph> tags. E.g something like this: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; $paragraphs = splitParagraphs($string); /* $paragraphs now contains: $paragraphs[0] = apples are red... $paragraphs[1] = john is a boy... $paragraphs[1] = this is dummy text... */ Any ideas? P.S it should be case insensitive, <paragraph>, <PARAGRAPH>, <Paragraph> should all be treated the same way.

    Read the article

  • replace string in java

    - by zahir
    i want how to replace the string in java example String a = "adf?sdf"; how can i replace these string.. or how can i avoid special characters. thanks and advacne..

    Read the article

  • string matching algorithms used by lucene

    - by iamrohitbanga
    i want to know the string matching algorithms used by Apache Lucene. i have been going through the index file format used by lucene given here. it seems that lucene stores all words occurring in the text as is with their frequency of occurrence in each document. but as far as i know that for efficient string matching it would need to preprocess the words occurring in the Documents. example: search for "iamrohitbanga is a user of stackoverflow" (use fuzzy matching) in some documents. it is possible that there is a document containing the string "rohit banga" to find that the substrings rohit and banga are present in the search string, it would use some efficient substring matching. i want to know which algorithm it is. also if it does some preprocessing which function call in the java api triggers it.

    Read the article

  • Converting from a string to boolean in Python?

    - by Joan Venge
    Does anyone know how to do convert from a string to a boolean in Python? I found this link. But it doesn't look like a proper way to do it. I.e. using a built in functionality, etc. EDIT: The reason I asked this is because I learned int("string"), from here. I tried bool ("string") but always got True.

    Read the article

  • Why does appending "" to a String save memory?

    - by hsmit
    I used a variable with a lot of data in it, say String data. I wanted to use a small part of this string in the following way: this.smallpart = data.substring(12,18); After some hours of debugging (with a memory visualizer) I found out that the objects field smallpart remembered all the data from data, although it only contained the substring. When I changed the code into: this.smallpart = data.substring(12,18)+""; ..the problem was solved! Now my application uses very little memory now! How is that possible? Can anyone explain this? I think this.smallpart kept referencing towards data, but why? UPDATE: How can I clear the big String then? Will data = new String(data.substring(0,100)) do the thing?

    Read the article

  • String replace in C#

    - by ile
    I'd like to use this method to create user-friendly URL. Because my site is in Croatian, there are characters that I wouldn't like to strip but replace them with another. Fore example, this string: ŠÐCŽ šdccž needs to be: sdccz-sdccz So, I would like to make two arrays, one that will contain characters that are to be replaced and other array with replacement characters: string[] character = { "Š", "Ð", "C", "C", "Ž", "š", "d", "c", "c", "ž" }; string[] characterReplace = { "s", "d", "c", "c", "z", "s", "d", "c", "c", "z" }; Finally, this two arrays should be use in some method that will take string, find matches and replace them. In php I used preg_replace function to deal with this. In C# this doesn't work: s = Regex.Replace(s, character, characterReplace); Would appreciate if someone could help. Thanks

    Read the article

  • Antlr Lexer Quoted String Predicate

    - by Loki
    I'm trying to build a lexer to tokenize lone words and quoted strings. I got the following: STRING: QUOTE (options {greedy=false;} : . )* QUOTE ; WS : SPACE+ { $channel = HIDDEN; } ; WORD : ~(QUOTE|SPACE)+ ; For the corner cases, it needs to parse: "string" word1" word2 As three tokens: "string" as STRING and word1" and word2 as WORD. Basically, if there is a last quote, it needs to be part of the WORD were it is. If the quote is surrounded by white spaces, it should be a WORD. I tried this rule for WORD, without success: WORD: ~(QUOTE|SPACE)+ | (~(QUOTE|SPACE)* QUOTE ~QUOTE*)=> ~(QUOTE|SPACE)* QUOTE ~(QUOTE|SPACE)* ;

    Read the article

  • Strlen of MAX 16 chars string using bitwise operators

    - by fabrizioM
    The challenge is to find the fastest way to determine in C/C++ the length of a c-string using bitwise operations in C. char thestring[16]; The c-string has a max size of 16 chars and is inside a buffer If the string is equal to 16 chars doesn't have the null byte at the end. I am sure can be done but didn't got it right yet. I am working on this at the moment, but assuming the string is memcpied on a zero-filled buffer. len = buff[0] != 0x0 + buff[1] != 0x0 + buff[2] != 0x0 + buff[3] != 0x0 + buff[4] != 0x0 + buff[5] != 0x0 + buff[6] != 0x0 + buff[7] != 0x0 + buff[8] != 0x0 + buff[9] != 0x0 + buff[10] != 0x0 + buff[11] != 0x0 + buff[12] != 0x0 + buff[13] != 0x0 + buff[14] != 0x0 + buff[15] != 0x0;

    Read the article

  • String literals vs constants for Session[...] dictionary keys

    - by FreshCode
    Session[Constant] vs Session["String Literal"] Performance I'm retrieving user-specific data like ViewData["CartItems"] = Session["CartItems"]; with a string literal for keys on every request. Should I be using constants for this? If yes, how should I go about implementing frequently used string literals and will it significantly affect performance on a high-traffic site? Related question does not address ASP.NET MVC or Session.

    Read the article

  • Finding the string length of a integer in .NET

    - by James Newton-King
    In .NET what is the best way to find the length of an integer in characters if it was represented as a string? e.g. 1 = 1 character 10 = 2 characters 99 = 2 characters 100 = 3 characters 1000 = 4 characters The obvious answer is to convert the int to a string and get its length but I want the best performance possible without the overhead of creating a new string.

    Read the article

  • Extracting a string starting with x and ending with y

    - by DMan
    First of all, I did a search on this and was able to find how to use something like String.Split() to extract the string based on a condition. I wasn't able to find however, how to extract it based on an ending condition as well. For example, I have a file with links to images: http://i594.photobucket.com/albums/tt27/34/444.jpghttp://i594.photobucket.com/albums/as/asfd/ghjk6.jpg You will notice that all the images start with http:// and end with .jpg. However, .jpg is succeeded by http:// without a space, making this a little more difficult. So basically I'm trying to find a way (Regex?) to extract a string from a string that starts with http:// and ends with .jpg

    Read the article

  • Easy way to Populate a Dictionary<string,List<string>>

    - by zion
    Greetings Guru's, my objective is to create a Dictionary of Lists, does a simpler technique exist? I prefer the List(t) to IEnumerable(t) which is why I chose the Dictionary of Lists over Ilookup or IGrouping. The code works but it seems like a messy way of doing things. string[] files = Directory.GetFiles (@"C:\test"); Dictionary<string,List<string>> DataX = new Dictionary<string,List<string>>(); foreach (var group in files.GroupBy (file => Path.GetExtension (file))) { DataX.Add (group.Key, group.ToList()); }

    Read the article

  • String replacement in PHP

    - by [email protected]
    This is my first question on this wonderful website. Lets say I have a string $a="some text..%PROD% more text" There will be just one %..% in the string. I need to replace PROD between the % with another variable content. So I used to do: $a = str_replace('%PROD%',$var,$a); but now the PROD between % started coming in different cases. So I could expect prod or Prod. So I made the entire string uppercase before doing replacement. But the side effect is that other letters in the original string also became uppercase. Someone suggested me to use regular expression. But how ? Thanks, Rohan

    Read the article

  • SQL Server Compact 'Data Directory' macro in Connection String - more info needed

    - by codeulike
    So, as described on this msdn page, when you define a Connection String for SQL Server Compact 3.5, you can use the "Data Directory" macro, like this: quote from this msdn page: Data Directory Support SQL Server Compact 3.5 now supports the Data Directory macro. This means that if you add the string |DataDirectory| (enclosed in pipe symbols) to a file path, it will resolve to the path of the database. For example, consider the connection string: "Data Source= c:\program files\MyApp\Mydb.sdf" When using Data Directory, you can instead use the following connection string: "Data Source = |DataDirectory|\Mydb.sdf" For more information, see How to: Deploy a SQL Server Compact 3.5 Database with an Application. However, the 'for more information' link on msdn doesn't actually give any more information. So my question is: How does the |Data Directory| macro translate at run time? For WinForm apps, it seems to just give the location of the executable. Or is it more complicated than that?

    Read the article

  • String.Format an integer to use 1000's separator without leading 0 for small integers

    - by Kragen
    Silly question, I want to format an integer so that it appears with the 1000's separator (,), but also without decimal places and without a leading 0. My attempts so far have been: String.Format("{0} {1}", 5, 5000); // 5 5000 String.Format("{0:n} {1:n}", 5, 5000); // 5.00 5,000.00 String.Format("{0:0,0} {1:0,0}", 5, 5000); // 05 5,000 The output I'm after is: 5 5,000 Is there something obvious that I'm missing?

    Read the article

  • A regular expression that will allow a string with only one Capital Letter

    - by Phoenix
    The string should be 6 - 20 characters in length. And it should contain 1 Capital letter. I can do this in code using C# string st = "SomeString" Regex rg = new Regex("[A-Z]"); MatchCollection mc = rg.Matches(st); Console.WriteLine("Total Capital Letters: " + mc.Count); if (mc.Count > 1) { return false; } But what i really want is a Regular expression that will match my string if it only contains one capital. The string can start with a common letter and should have only letters. Thanks In advance. (I did look at some of the other RegEx questions but they did not help).

    Read the article

  • Auto Encryption of web.config connection string

    - by Klaas Jan
    I want to encrypt the connection string in web.config, the problem is each time a developer changes the connection string in web.config and publishes, it needs to be encrypted every time in the web server. Is there any way that the connection string can encrypted automatically every time someone publishes it? Note :- All of us work on our local machines other than the server. So encryption using local machine key is not an option.

    Read the article

  • C String literals: Where do they go?

    - by Chris Cooper
    I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory. I am interested in where the string DOES get allocated/stored, etc. I did find one intriguing answer here, saying: Defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smart trick, don't bother). but, it had to do with C++, not to mention that it says not to bother. I am bothering. =D So my question is, again, where and how is my string literal kept? Why should I not try to alter it? Does the implementation vary by platform? Does anyone care to elaborate on the "smart trick?" Thanks for any explanations.

    Read the article

  • C# - How do find a string within a string even if it spans across whitespace?

    - by James Heaney
    I want to be able to find and highlight a string within a string BUT I no not want to remove the space. So if my original string is : There are 12 monkeys I want to find '12 mon' and highlight those characters ending up with : There are < font color='red' 12 mon< /font keys BUT I also want the same result if I search for '12mon' (no space this time) This has really bent my mind! I'm sure it can be done with Regex.

    Read the article

  • How do I create a Solution Wide Connection String

    - by Renier
    Hi. Does anyone know if it is possible to create a single connection string that will be accessible to all the projects in a solution (we have about 6). I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution. We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design time support Regards, Renier

    Read the article

  • C# - split String into smaller Strings by length variable

    - by tyndall
    I'd like to break apart a String by a certain length variable. It needs to bounds check so as not explode when the last section of string is not as long as or longer than the length. Looking for the most succinct (yet understandable) version. Example: string x = "AAABBBCC"; string[] arr = x.SplitByLength(3); // arr[0] -> "AAA"; // arr[1] -> "BBB"; // arr[2] -> "CC"

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >