Search Results

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

Page 174/1413 | < Previous Page | 170 171 172 173 174 175 176 177 178 179 180 181  | Next Page >

  • Python - Removing duplicates from a string

    - by Daniel
    def remove_duplicates(strng): """ Returns a string which is the same as the argument except only the first occurrence of each letter is present. Upper and lower case letters are treated as different. Only duplicate letters are removed, other characters such as spaces or numbers are not changed. >>> remove_duplicates('apple') 'aple' >>> remove_duplicates('Mississippi') 'Misp' >>> remove_duplicates('The quick brown fox jumps over the lazy dog') 'The quick brown fx jmps v t lazy dg' >>> remove_duplicates('121 balloons 2 u') '121 balons 2 u' """ s = strng.split() return strng.replace(s[0],"") Writing a function to get rid of duplicate letters but so far have been playing around for an hour and can't get anything. Help would be appreciated, thanks.

    Read the article

  • c# warn if text box is empty or contains a non-whole number

    - by Jamaul Smith
    In my specific case, I need the value in propertyPriceTextBox to be numeric only, and a whole number. A value also has to be entered, and I can just Messagebox.Show() a warning and that's all I'd need to do. This is what I have so far. private void computeButton_Click(object sender, EventArgs e) { decimal propertyPrice; if ((decimal.TryParse(propertyPriceTextBox.Text, out propertyPrice))) decimal.Parse(propertyPriceTextBox.Text); { if (residentialRadioButton.Checked == true) commisionLabel.Text = (residentialCom * propertyPrice).ToString("c"); if (commercialRadioButton.Checked == true) commisionLabel.Text = (commercialCom * propertyPrice).ToString("c"); if (hillsRadioButton.Checked == true) countySalesTaxTextBox.Text = ( hilssTax * propertyPrice).ToString("c"); if (pascoRadioButton.Checked == true) countySalesTaxTextBox.Text = (pascoTax * propertyPrice).ToString("c"); if (polkRadioButton.Checked == true) countySalesTaxTextBox.Text = (polkTax * propertyPrice).ToString("c"); decimal result; result = (countySalesTaxTextBox.Text + stateSalesTaxTextBox.Text + propertyPriceTextBox.Text + comissionTextBox.Text).ToString("c"); } else (.) MessageBox.Show("Property Price must be a whole number."); }

    Read the article

  • Sort Strings by first letter [C]

    - by Blackbinary
    I have a program which places structures in a linked list based on the 'name' they have stored in them. To find their place in the list, i need to figure out if the name im inserting is earlier or later in the alphabet then those in the structures beside it. The names are inside the structures, which i have access to. I don't need a full comaparison if that is more work, even just the first letter is fine. Thanks for the help!

    Read the article

  • Url Rewriting with Querystrings

    - by Alon
    In IIS 7.5, I'm trying to rewrite a Url such as /about to /content.asp?p=about, with support for QueryString-s, so if the orginal Url was /about?x=y, it should rewrite to /content.asp?p=about&x=y. The basic rewriting is now working, but when I'm trying to add a QueryString it doesn't work. Tried both /about?x=y and /about&x=y. My current rule: <rule name="RewriteUserFriendlyURL1" stopProcessing="false"> <match url="^([^/]+)/?$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="content.asp?p={R:1}" /> </rule> How can I fix this? Thank you.

    Read the article

  • Javascript string.replace with regex

    - by Jimbo
    I want to replace a url querystring parameter with a new value if it already exists or add it on if not. e.g. The current url could be: a. www.mysite.com/whatever.asp?page=5&version=1 OR b. www.mysite.com/whatever.asp?version=1 I need the resulting url to be www.mysite.com/whatever.asp?page=1&version=1 I suspect I can use string.replace with a regex to do this the most intelligent way but am hoping for a little help with it from someone more experienced with regexs :) Thanks!

    Read the article

  • How do you convert a string to a node in XQuery?

    - by Sixty4Bit
    I would like to convert a string into a node. I have a method that is defined to take a node, but the value I have is a string (it is hard coded). How do I turn that string into a node? So, given an XQuery method: define function foo($bar as node()*) as node() { (: unimportant details :) } I have a string that I want to pass to the foo method. How do I convert the string to a node so that the method will accept the string.

    Read the article

  • Why RichTextBox lose format after appending new String?

    - by user556526
    Hi guys I have aproblem with rich text box string color: I have the richtexbox that user type a message in it. I mark up each word that exist in my dictionary. I use this code for it: this.inputTextAreaRtb.Text=this.inputTextAreaRtb.Text.Remove(startCoordinate, endCoordinate - startCoordinate); this.inputTextAreaRtb.SelectionStart = this.inputTextAreaRtb.Text.Length; this.inputTextAreaRtb.SelectionLength = 0; this.inputTextAreaRtb.SelectionFont = new System.Drawing.Font( "David", 12, FontStyle.Underline); this.inputTextAreaRtb.SelectionColor = Color.DarkBlue; this.inputTextAreaRtb.AppendText(_word); this.inputTextAreaRtb.SelectionColor = this.inputTextAreaRtb.ForeColor; this.inputTextAreaRtb.SelectionFont = new System.Drawing.Font( "David", 12, FontStyle.Regular); But each time if I already marked up a word a loose formatting of words that already formatted. Any ideas of this problem?

    Read the article

  • Perl - string matching issue

    - by user2886545
    I have a problem I cannot understand. I have this string: gene_id "siRNA_Z27kG1_20543"transcript_id "siRNA_Z27kG1_20543_X_1";tss_id "TSS124620" And I want to change the gene_id. So, I have the following code: if ($line =~ /;transcript_id "([A-Za-z0-9:\-._]*)(_[oxOX][_.][0-9]*)";/) { $num = $2; $line =~ s/gene_id "([A-Za-z0-9:\-._]*)";/gene_id "$1$num";/g; print $new $line."\n"; } The aim of my code is to change siRNA_Z27kG1_20543 for siRNA_Z27kG1_20543_X_1. However, my code does not produce that output. Why? I can't understand that. My regex needs to be as it is because I match other strings (this time with success). Thanks.

    Read the article

  • Checking if a string's characters are ascending alphabetically and its ascent is evenly spaced python

    - by FRU5TR8EDD
    So need to check if a string's characters are ascending alphabetically and if that ascent is evenly spaced. a = "abc" b = "ceg" So a is alphabetically ascending and it's spacing is 1 (if you convert to the ordinal values they are 97,98,99). And b is also alphabetically ascending and it's spacing is 2 (99,101,103). And I am sticking with the following code: a = 'jubjub' words1 = [] ords = [ord(letter) for letter in a] diff = ords[1] - ords[0] for ord_val in range(1, len(ords)-1): if diff > 0: if ords[ord_val + 1] - ords[ord_val] == diff: if a not in words1: words1.append((a, diff)) print words1 How come 'jubjub' works, 'ace' works, but 'catcat' doesn't?

    Read the article

  • (C++) If statement not effective

    - by Galileo
    void spriteput(int x,int y, int stype) { char sprite1[5]="OOOO"; char sprite2[5]="OOOO"; char sprite3[5]="OOOO"; char sprite4[5]="OOOO"; if (stype == 1) { char sprite1[5] = " OO "; char sprite2[5] = "OOOO"; char sprite3[5] = "OOOO"; char sprite4[5] = " OO "; mvprintw(2,y,"%s \n",sprite1); } mvprintw(x+1,y,"%s \n",sprite2); mvprintw(x+2,y,"%s \n",sprite3); mvprintw(x+3,y,"%s \n",sprite4); } If I'm correct that block of code should print out on a NCURSES screen OO OOOO OOOO OO Instead however, it prints out the default text (the first char statements). Can anyone tell me why this is? The "printw" statement inside the If-block prints out the proper text, so it's being assigned correctly. Thank you in advance.

    Read the article

  • Detect non-closed connections to SQL

    - by JoeJoe
    I've inherited a very large project in ASP.net, SQL 2005 and have found where some SQL connections are not closed - which is bad. Without going thru every line of code, is there a way to detect if connections are not being closed? Performance counter? as a follow up - how does SQL reclaim unclosed connections. I'm using non-pooled connectionstring.

    Read the article

  • replacing the beginning and end but not the same chars within a string

    - by Jordan Trainor
    lines = "some stuff\"some other \"stuff\"\""; lines = lines.Replace("\"", "\""); lines = lines.Replace("\"", "\""); in its current context and in its simplest form these two actions seem absolutely pointless but when I put this into code it will be not be pointless and will have a purpose other than replacing itself with itself. OK so I have the String lines that has 4 escaped quotation marks and I wish to replace the first quote with a quote and the end quote with a quote how would I accomplish this without replacing any of the inner quotes?

    Read the article

  • ASP.NET MVC4: How to convert an IEnumerable to a string for ViewBag

    - by sehummel
    This is what I'm trying to do, but it doesn't work: HardwareType hwt = new HardwareType { HType = "PC" }; IEnumerable<Hardware> Pcs = db.Hardware.Where(h => h.HardwareType.Contains(hwt)); ViewBag.Pcs = Pcs.ToString(); So how do I convert my IEnumerable to a string (or other primitive data type) so the compiler won't give me an error when I try to use it in my Razor? @foreach (var item in ViewBag.Pcs) { <li><a href="#" class="btn"><i class="icon-hdd"></i> @item.HType</a></li> }

    Read the article

  • Most reliable split character

    - by JL
    Update If you were forced to use a single char on a split method, which char would be the most reliable? Definition of reliable: a split character that is not part of the individual sub strings being split.

    Read the article

  • Get Array value by string of keys

    - by Esben Petersen
    Hello, i'm building a template engine for my next project, which is going great. It replaces {tag} with a corresponding value. But, i want {tag[0][key]} to be replaced as well. All i need to know is how to get the value, if i have the string representation of the array and key, like this: $arr = array( 0=>array( 'key'=>'value' ), 1=>array( 'key'=>'value2' ) ); $tag = 'arr[0][key]'; echo($$tag); This is a very simple version of the problem, i hope you understand it. Or else i would be happy to anwser any questions about it :) Thanks for any help in advantage

    Read the article

  • Getting the last element of a Postgres array, declaratively

    - by Wojciech Kaczmarek
    How to obtain the last element of the array in Postgres? I need to do it declaratively as I want to use it as a ORDER BY criteria. I wouldn't want to create a special PGSQL function for it, the less changes to the database the better in this case. In fact, what I want to do is to sort by the last word of a specific column containing multiple words. Changing the model is not an option here. In other words, I want to push Ruby's sort_by {|x| x.split[-1]} into the database level. I can split a value into array of words with Postgres string_to_array or regexp_split_to_array functions, then how to get its last element?

    Read the article

  • MS Excel 03 - Deleting rows that have live string identifiers in column A, while concatenating other

    - by Justin
    I have this xml document that is provided as a data feed (right off the bat I can not modify the source of the data feed) and i import it into excel with the xml import. there is no schema that comes with this xml so i get a table that ends up having a whole bunch of duplicates for an identifier, because of the unique values spread throughout the spreadsheet. XML in XLS Col1(IDnum) Col2(name) Col3(Type) Col4(Category) Col(etc) ================================================================= 0011 Item 01 6B 0011 Item xxj9 7B 0011 Item xxj9 0011 Item 02 0011 Item 01 xxj9 6B 0012 etc I need to delete all rows where columnA string/number matches while concatenating all potential values from Col3, Col4 & Col5 together so it looks like this Col1(IDnum) Col2(name) Col3(Type) Col4(Category) Col(etc) ================================================================= 0011 Item 01, 02 xxj9 6B, 7B what visual basic method would allow me to accomplish this? thanks

    Read the article

  • C appending char to char*

    - by Ostap Hnatyuk
    So I'm trying to append a char to a char*. For example I have char *word = " "; I also have char ch = 'x'; I do append(word, ch); Using this method.. void append(char* s, char c) { int len = strlen(s); s[len] = c; s[len+1] = '\0'; } It gives me a segmentation fault, and I understand why I suppose. Because s[len] is out of bounds. How do I make it so it works? I need to clear the char* a lot as well, if I were to use something like char word[500]; How would I clear that once it has some characters appended to it? Would the strlen of it always be 500? Thanks in advance.

    Read the article

  • Need a Concatenating VBA code to prevent memory issue workaround

    - by doharr
    My set up: Have 50,000 rows of data. ( My row count will increase in the future. So might as well say I have a full worksheet of 64000+ rows.) All Data is TEXT, no formulas, etc. Column A is open Columns B thru AC contain the Data that needs to be concatenated The Data in the rows once concatenated to Column A will contain 60,000 digits or 6kb in file size. After additional maniuplation each cell will become a file. I have tried concatenating in Excel and I run into memory issues. The memory issue is when I Select and fill down the concatenating function into the worksheet. It crashes at the 8200 +/-row. My system is 2gb of ram, windows xp professional and Excel 2003. Have 4GB of disk space Hoping to find a VBA code that will conserve memory, and not crash like it does in excel. Thank you

    Read the article

  • why nResult != nConvertedLen,when use CComBSTR;

    - by hxboxy
    CComBSTR wsData = (char*)pvData; when constuct CComBSTR,call A2WBSTR,but sometimes nResult != nConvertedLen,just 1/20. why? inline BSTR A2WBSTR(_In_opt_ LPCSTR lp, int nLen = -1) { if (lp == NULL || nLen == 0) return NULL; USES_CONVERSION_EX; BSTR str = NULL; #pragma warning(push) #pragma warning(disable: 6385) int nConvertedLen = MultiByteToWideChar(_acp_ex, 0, lp, nLen, NULL, NULL); #pragma warning(pop) int nAllocLen = nConvertedLen; if (nLen == -1) nAllocLen -= 1; // Don't allocate terminating '\0' str = ::SysAllocStringLen(NULL, nAllocLen); if (str != NULL) { int nResult; nResult = MultiByteToWideChar(_acp_ex, 0, lp, nLen, str, nConvertedLen); ATLASSERT(nResult == nConvertedLen); if(nResult != nConvertedLen) { SysFreeString(str); return NULL; } } return str; }

    Read the article

  • Instantiating class by string using PHP 5.3 namespaces

    - by Kevin
    I can't get around an issue instantiating a new class by using a string variable and PHP 5.3. namespaces. For example, this works; $class = 'Reflection'; $object = new $class(); However, this does not; $class = '\Application\Log\MyClass'; $object = new $class(); A fatal error gets thrown stating the class cannot be found. However it obviously can be instantiated if using the FQN i.e.; $object = new \Application\Log\MyClass; I've found this to be aparrent on PHP 5.3.2-1 but not not in later versions. Is there a work around for this?

    Read the article

< Previous Page | 170 171 172 173 174 175 176 177 178 179 180 181  | Next Page >