Search Results

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

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

  • 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 literals in python

    - by kjakeb
    Hello, Is there a way to declare a string variable in python such that everything inside of it is automatically escaped, or has its literal character value? I'm NOT asking how to escape the quotes with slashes, that's obvious. What I'm asking for is a general purpose way for making EVERYTHING in a string literal so that I don't have to manually go through and escape everything for very large strings. Anyone know of a solution? Thanks!

    Read the article

  • String literals C++?

    - by Bad Man
    I need to do the following C# code in C++ (if possible). I have to const a long string with lots of freaking quotes and other stuff in it. const String _literal = @"I can use "quotes" inside here";

    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

  • Python/Django Concatenate a string depending on whether that string exists

    - by Douglas Meehan
    I'm creating a property on a Django model called "address". I want address to consist of the concatenation of a number of fields I have on my model. The problem is that not all instances of this model will have values for all of these fields. So, I want to concatenate only those fields that have values. What is the best/most Pythonic way to do this? Here are the relevant fields from the model: house = models.IntegerField('House Number', null=True, blank=True) suf = models.CharField('House Number Suffix', max_length=1, null=True, blank=True) unit = models.CharField('Address Unit', max_length=7, null=True, blank=True) stex = models.IntegerField('Address Extention', null=True, blank=True) stdir = models.CharField('Street Direction', max_length=254, null=True, blank=True) stnam = models.CharField('Street Name', max_length=30, null=True, blank=True) stdes = models.CharField('Street Designation', max_length=3, null=True, blank=True) stdessuf = models.CharField('Street Designation Suffix',max_length=1, null=True, blank=True) I could just do something like this: def _get_address(self): return "%s %s %s %s %s %s %s %s" % (self.house, self.suf, self.unit, self.stex, self.stdir, self.stname, self.stdes, self.stdessuf) but then there would be extra blank spaces in the result. I could do a series of if statements and concatenate within each, but that seems ugly. What's the best way to handle this situation? Thanks.

    Read the article

  • collect string in loop and printout all the string outside loop

    - by user1508163
    I'm newbie here and there is some question that I want have some lesson from you guys. For example: #include <stdio.h> #include<stdlib.h> #include<ctype.h> void main() { char name[51],selection; do { printf("Enter name: "); fflush(stdin); gets(name); printf("Enter another name?(Y/N)"); scanf("%c",&selection); selection=toupper(selection); }while (selection=='Y'); //I want to printout the entered name here but dunno the coding printf("END\n"); system("pause"); } As I know when the loops perform will overwrite the variable then how I perform a coding that will printout all the name user entered? I have already ask my tutor and he is ask me to use pointer, can anyone guide me in this case?

    Read the article

  • Xml Literals

    XML Literals allow you to use XML syntax in your code. It’s easy to work with XML files this way, since you have that Tags in the code, but it’s also quicker to access information rather then the traditional methods.

    Read the article

  • Xml Literals

    XML Literals allow you to use XML syntax in your code. Its easy to work with XML files this way, since you have that Tags in the code, but its also quicker to access information rather then the traditional methods....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Why use string.Empty over "" when assigning to a string object

    - by dreza
    I've been running StyleCop over my code and one of the recommendations SA1122 is to use string.Empty rather than "" when assigning an empty string to a value. My question is why is this considered best practice. Or, is this considered best practice? I assume there is no compiler difference between the two statements so I can only think that it's a readability thing? UPDATE: Thanks for the answers but it's been kindly pointed out this question has been asked many times already on SO, which in hind-sight I should have considered and searched first before asking here. Some of these especially forward links makes for interesting reading. SO question and answer Jon Skeet answer to question

    Read the article

  • What's a good way of building up a String given specific start and end locations?

    - by Michael Campbell
    (java 1.5) I have a need to build up a String, in pieces. I'm given a set of (sub)strings, each with a start and end point of where they belong in the final string. Was wondering if there were some canonical way of doing this. This isn't homework, and I can use any licensable OSS, such as jakarta commons-lang StringUtils etc. My company has a solution using a CharBuffer, and I'm content to leave it as is (and add some unit tests, of which there are none (?!)) but the code is fairly hideous and I would like something easier to read. As I said this isn't homework, and I don't need a complete solution, just some pointers to libraries or java classes that might give me some insight. The String.Format didn't seem QUITE right... I would have to honor inputs too long and too short, etc. Substrings would be overlaid in the order they appear (in case of overlap). As an example of input, I might have something like: String:start:end FO:0:3 (string shorter than field) BAR:4:5 (String larger than field) BLEH:5:9 (String overlays previous field) I'd want to end up with FO BBLEH 01234567890

    Read the article

  • What's a good way of building up a String where you specific start and end locations?

    - by Michael Campbell
    (java 1.5) I have a need to build up a String, in pieces. I'm given a set of (sub)strings, each with a start and end point of where they belong in the final string. Was wondering if there were some canonical way of doing this. This isn't homework, and I can use any licensable OSS, such as jakarta commons-lang StringUtils etc. My company has a solution using a CharBuffer, and I'm content to leave it as is (and add some unit tests, of which there are none (?!)) but the code is fairly hideous and I would like something easier to read. As I said this isn't homework, and I don't need a complete solution, just some pointers to libraries or java classes that might give me some insight. The String.Format didn't seem QUITE right... I would have to honor inputs too long and too short, etc. Substrings would be overlaid in the order they appear (in case of overlap). As an example of input, I might have something like: String:start:end FO:0:3 (string shorter than field) BAR:4:5 (String larger than field) BLEH:5:9 (String overlays previous field) I'd want to end up with FO BBLEH 01234567890

    Read the article

  • iPhone OS: making a switch statement that uses string literals as comparators instead of integers

    - by nickthedude
    So i'd like to do this: switch (keyPath) { case @"refreshCount": //do stuff case @"timesLaunched": //do other stuff } but apparently you can only use integers as the switch quantity. Is the only way to do this parse the string into an integer identifier and then run the switch statement? like this: nsinteger num = nil; if (keyPath isEqual:@"refreshCount") { num = 0 } if (keyPath isEqual:@"timesLaunched") { num = 1 } I'm trying to optimize this code to be as quick as possible because its going to get called quite often. thanks, Nick

    Read the article

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