Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 179/1488 | < Previous Page | 175 176 177 178 179 180 181 182 183 184 185 186  | Next Page >

  • How to calculate this string-dissimilarity function efficiently?

    - by ybungalobill
    Hello, I was looking for a string metric that have the property that moving around large blocks in a string won't affect the distance so much. So "helloworld" is close to "worldhello". Obviously Levenshtein distance and Longest common subsequence don't fulfill this requirement. Using Jaccard distance on the set of n-grams gives good results but has other drawbacks (it's a pseudometric and higher n results in higher penalty for changing single character). [original research] As I thought about it, what I'm looking for is a function f(A,B) such that f(A,B)+1 equals the minimum number of blocks that one have to divide A into (A1 ... An), apply a permutation on the blocks and get B: f("hello", "hello") = 0 f("helloworld", "worldhello") = 1 // hello world -> world hello f("abba", "baba") = 2 // ab b a -> b ab a f("computer", "copmuter") = 3 // co m p uter -> co p m uter This can be extended for A and B that aren't necessarily permutations of each other: any additional character that can't be matched is considered as one additional block. f("computer", "combuter") = 3 // com uter -> com uter, unmatched: p and b. Observing that instead of counting blocks we can count the number of pairs of indices that are taken apart by a permutation, we can write f(A,B) formally as: f(A,B) = min { C(P) | P:|A|?|B|, P is bijective, ?i?dom(P) A[P(i)]=B[P(i)] } C(P) = |A| + |B| - |dom(P)| - |{ i | i,i+1?dom(P) and P(i)+1=P(i+1) }| - 1 The problem is... guess what... ... that I'm not able to calculate this in polynomial time. Can someone suggest a way to do this efficiently? Or perhaps point me to already known metric that exhibits similar properties?

    Read the article

  • Windows batch - loop over folder string and parse out last folder name

    - by Tim Peel
    Hi, I need to grab the folder name of a currently executing batch file. I have been trying to loop over the current directory using the following syntax (which is wrong at present): set mydir = %~p0 for /F "delims=\" %i IN (%mydir%) DO @echo %i Couple of issues in that I cannot seem to pass the 'mydir' variable value in as the search string. It only seems to work if I pass in commands; I have the syntax wrong and cannot work out why. My thinking was to loop over the folder string with a '\' delimiter but this is causing problems too. If I set a variable on each loop then the last value set will be the current folder name. For example, given the following path: C:\Folder1\Folder2\Folder3\Archive.bat I would expect to parse out the value 'Folder3'. I need to parse that value out as its name will be part of another folder I am going to create further down in the batch file. Many thanks if anyone can help. I may be barking up the wrong tree completely so any other approaches would be greatly received also. Tim

    Read the article

  • C# string syntax error

    - by Mesa
    I'm reading in data from a file and trying to write only the word immediately before 'back' in red text. For some reason it is displaying the word and then the word again backwords. Please help. Thank you. private void Form1_Load(object sender, EventArgs e) { Regex r = new Regex(" "); StreamReader sr = new StreamReader("KeyLogger.txt"); string[] tokens = r.Split(sr.ReadToEnd()); int index = 0; for(int i = 0; i <= tokens.Length; i++) { if (tokens[i].Equals("back")) { //richTextBox1.Text+="TRUE"; richTextBox1.SelectionColor = Color.Red; string myText; if (tokens[i - 1].Equals("back")) myText = ""; else myText = tokens[i - 1]; richTextBox1.SelectedText = myText; richTextBox1.Text += myText; } else { //richTextBox1.Text += "NOOOO"; } //index++; //richTextBox1.Text += index; } }

    Read the article

  • Decrypting a string in C# 3.5 which was encrypted with openssl in php 5.3.2

    - by panny
    Hi everyone, maybe someone can clear me up. I have been surfing on this a while now. I used openssl from console to create a root certificate for me (privatekey.pem, publickey.pem, mycert.pem, mycertprivatekey.pfx). See the end of this text on how. The problem is still to get a string encrypted on the PHP side to be decrypted on the C# side with RSACryptoServiceProvider. Any ideas? PHP side I used the publickey.pem to read it into php: $server_public_key = openssl_pkey_get_public(file_get_contents("C:\publickey.pem")); // rsa encrypt openssl_public_encrypt("123", $encrypted, $server_public_key); and the privatekey.pem to check if it works: openssl_private_decrypt($encrypted, $decrypted, openssl_get_privatekey(file_get_contents("C:\privatekey.pem"))); Coming to the conclusion, that encryption/decryption works fine on the php side with these openssl root certificate files. C# side In same manner I read the keys into a .net C# console program: X509Certificate2 myCert2 = new X509Certificate2(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); try { myCert2 = new X509Certificate2(@"C:\mycertprivatekey.pfx"); rsa = (RSACryptoServiceProvider)myCert2.PrivateKey; } catch (Exception e) { } string t = Convert.ToString(rsa.Decrypt(rsa.Encrypt(test, false), false)); coming to the point, that encryption/decryption works fine on the c# side with these openssl root certificate files. key generation on unix 1) openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout privatekey.pem -out mycert.pem 2) openssl rsa -in privatekey.pem -pubout -out publickey.pem 3) openssl pkcs12 -export -out mycertprivatekey.pfx -in mycert.pem -inkey privatekey.pem -name "my certificate"

    Read the article

  • convert htmlelement to string for comparison javascript

    - by Jamex
    Hi, I am using a function that obtains a target element id at onclick. Example, if I click on the text element that has the id of 'help'. var click = (e && e.target) || (event && event.srcElement); The var click would contain the ref to the id of "help". I want to compare the var click to the string 'help' using the if statement below. if (click == 'about') {do something} The comparison does not work because the var click is not a string. When I use the alert(click) to debug, it shows click as "object HTMLElement". How would you compare whether the id 'help' is obtained from var click? I could write out something like if (click == document.getElementById('help')) {do something} but that would make a long statement. also if the var click is document.getElementById('help'), how would you make a new var "show" as document.getElementById('showhelp') basically, I want to use the same function to generate dynamic responses to each element that was clicked on, and not having to create a separate function for each element.

    Read the article

  • VB.NET - Find a Substring in an ArrayList, StringCollection or List(Of String)

    - by CJM
    I've got some code that creates a list of AD groups that the user is a member of, with the intention of saying 'if user is a member of GroupX then allow admin access, if not allow basic access'. I was using a StringCollection to store this list of Groups, and intended to use the Contains method to test for membership of my admin group, but the problem is that this method only compares the full string - but my AD groups values are formatted as cn=GroupX, etc.... I want to be easily able to determine if a particular substring (i.e. 'GroupX') appears in the list of groups. I could always iterate through the groups check each for a substring representing my AD group name, but I'm more interested in finding out if there is a 'better' way. Clearly there are a number of repositories for the list of Groups, and it appears that Generics (List(Of String)) are more commonly preferred (which I may well implement anyway) but there is no in-built means of checking for a substring using this method either. Any suggestions? Or should I just iterated through the list of groups?

    Read the article

  • String Parameter in url

    - by Ivan90
    Hy Guys, I have to pass in a method action a string parameter, because I want to implement a tags' search in my site with asp.net MVC but everytime in action it is passed a null value. I post some code! I try to create a personal route. routes.MapRoute( "TagsRoute", "Tags/PostList/{tag}", new {tag = "" } ); My RouteLink in a viewpage for each tag is: <% foreach (var itemtags in item.tblTagArt) {%> <%= Html.RouteLink(itemtags.Tags.TagName,"TagsRoute", new {tag=itemtags.Tags.TagName})%>, <% } %> My method action is: public ActionResult PostList(string tag) { if (tag == "") { return RedirectToAction("Index", "Home"); } else { var articoli = artdb.GetArticoliByTag(tag); if (articoli == null) { return RedirectToAction("Index", "Home"); } return View(articoli); } } Problem is value tag that's always null, and so var articoli is always empty! Probably my problem is tag I have to make a route contrainst to my tag parameter. Anybody can help me? N.B I am using ASP.NET MVC 1.0 and not 2.0!

    Read the article

  • Converting Python Script to Vb.NET - Involves Post and Input XML String

    - by Jason Shoulders
    I'm trying to convert a Python Script to Vb.Net. The Python Script appears to accept some XML input data and then takes it to a web URL and does a "POST". I tried some VB.NET code to do it, but I think my approach is off because I got an error back "BadXmlDataErr" plus I can't really format my input XML very well - I'm only doing string and value. The input XML is richer than that. Here is an example of what the XML input data looks like in the Python script: <obj is="MyOrg:realCommand_v1/" > <int name="priority" val="1" /> <real name="value" val="9.5" /> <str name="user" val="MyUserName" /> <reltime name="overrideTime" val="PT60S"/> </obj> Here's the Vb.net code I attempted to convert that: Dim reqparm As New Specialized.NameValueCollection reqparm.Add("priority", "1") reqparm.Add("value", "9.5") reqparm.Add("user", "MyUserName") reqparm.Add("overrideTime", "PT60S") Using client As New Net.WebClient Dim sTheUrl As String = "[My URL]" Dim responsebytes = client.UploadValues(sTheUrl, "POST", MyReqparm) Dim responsebody = (New System.Text.UTF8Encoding).GetString(responsebytes) End Using I feel like I should be doing something else. Can anyone point me to the right direction?

    Read the article

  • How to take a Serialized String from the DB and output a UL list with Coldfusion

    - by nobosh
    Given a string from the database as follows: ul[0][id]=main1&ul[0][children][0][id]=child2&ul[0][children][0][class]=&ul[1][id]=main3&ul[2][id]=main4&ul[3][id]=main5 Where what's after the equal sign is an ID, how can I take this string on the backend and build out a list as following from front-end output? <UL id="container"> <LI id="main1"> Lorem ipsum dolor sit amet, consectetur <UL> <LI id="child2"> In hac habitasse platea dictumst. <UL></UL> </LI> </UL> </LI> <LI id="main3"> In hac habitasse platea dictumst. <UL></UL> </LI> <LI id="main4"> In hac habitasse platea dictumst. <UL></UL> </LI> <LI id="main5"> In hac habitasse platea dictumst. <UL></UL> </LI> </UL> Thanks

    Read the article

  • Weird exception: Cannot cast String to Boolean when using getBoolean

    - by La bla bla
    I'm getting a very weird error. I have 2 activities. On both I'm getting the SharedPreferences using MODE_PRIVATE (if it matters) by sp = getPreferences(MODE_PRIVATE); on each activity's onCreate() I'm calling sp.getBoolean(IntroActivity.SHOW_INTRO, true) On the IntroActivity this works fine. But when I'm trying in the main activity, I'm getting this 10-12 04:55:23.208: E/AndroidRuntime(11668): FATAL EXCEPTION: main 10-12 04:55:23.208: E/AndroidRuntime(11668): java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:242) 10-12 04:55:23.208: E/AndroidRuntime(11668): at com.lablabla.parkme.ParkMeActivity$2.onClick(ParkMeActivity.java:194) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.view.View.performClick(View.java:4084) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.view.View$PerformClick.run(View.java:16966) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.os.Handler.handleCallback(Handler.java:615) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.os.Handler.dispatchMessage(Handler.java:92) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.os.Looper.loop(Looper.java:137) 10-12 04:55:23.208: E/AndroidRuntime(11668): at android.app.ActivityThread.main(ActivityThread.java:4745) 10-12 04:55:23.208: E/AndroidRuntime(11668): at java.lang.reflect.Method.invokeNative(Native Method) 10-12 04:55:23.208: E/AndroidRuntime(11668): at java.lang.reflect.Method.invoke(Method.java:511) 10-12 04:55:23.208: E/AndroidRuntime(11668): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-12 04:55:23.208: E/AndroidRuntime(11668): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-12 04:55:23.208: E/AndroidRuntime(11668): at dalvik.system.NativeStart.main(Native Method) I made sure that I'm not putting a String somewhere in the middle with that same key Any ideas? Thanks! EDIT: some code: //onCreate() sp = getPreferences(MODE_PRIVATE); // other method boolean showIntro = sp.getBoolean(IntroActivity.SHOW_INTRO, true); // Exception is here showIntroCheckBox.setChecked(showIntro); If it matters, the code which throws the exception is inside a button's onClick

    Read the article

  • Search string in file (C)

    - by chutsu
    So my code isn't working... test.c:27: warning: passing argument 1 of ‘search’ from incompatible pointer type which is the fgets line. My code opens a file, reads the file line by line, and I'm trying to create a "search" function that will return a value that indicates whether that string is found on that line of the file. My ultimate goal is to achieve a search and replace program. But one step at a time eh? this is what I have so far: #include <stdio.h> #include <string.h> int search(const char *content[], const char *search_term) { int t; for(t=0; content[t]; ++t){ if(!strcmp(content[t], search_term)){ return t; // found } } return 0; // not found } int main(int argc, char *argv[]) { FILE *file; char line[BUFSIZ]; int linenumber=0; char term[20] = "hello world"; file = fopen(argv[1], "r"); if(file != NULL){ while(fgets(line, sizeof(line), file)){ if(search(line, term) != -1){ printf("Search Term Found!!\n"); } ++linenumber; } } else{ perror(argv[1]); } fclose(file); return 0; }

    Read the article

  • Replacing words in string

    - by abkai
    Okay, so I have the following little function: def swap(inp): inp = inp.split() out = "" for item in inp: ind = inp.index(item) item = item.replace("i am", "you are") item = item.replace("you are", "I am") item = item.replace("i'm", "you're") item = item.replace("you're", "I'm") item = item.replace("my", "your") item = item.replace("your", "my") item = item.replace("you", "I") item = item.replace("my", "your") item = item.replace("i", "you") inp[ind] = item for item in inp: ind = inp.index(item) item = item + " " inp[ind] = item return out.join(inp) Which, while it's not particularly efficient gets the job done for shorter sentences. Basically, all it does is swaps pronoun etc. perspectives. This is fine when I throw a string like "I love you" at it, it returns "you love me" but when I throw something like: you love your version of my couch because I love you, and you're a couch-lover. I get: I love your versyouon of your couch because I love I, and I'm a couch-lover. I'm confused as to why this is happening. I explicitly split the string into a list to avoid this. Why would it be able to detect it as being a part of a list item, rather than just an exact match? Also, slightly deviating to avoid having to post another question so similar; if a solution to this breaks this function, what will happen to commas, full stops, other punctuation? It made some very surprising mistakes. My expected output is: I love my version of your couch because you love I, and I'm a couch-lover. The reason I formatted it like this, is because I eventually hope to be able to replace the item.replace(x, y) variables with words in a database.

    Read the article

  • Quickly or concisely determine the longest string per column in a row-based data collection

    - by ccornet
    Judging from the failure of my last inquiry, I need to calculate and preset the widths of a set of columns in a table that is being made into an Excel file. Unfortunately, the string data is stored in a row-based format, but the widths must be calculated in a column-based format. The data for the spreadsheets are generated from the following two collections: var dictFiles = l.Items.Cast<SPListItem>().GroupBy(foo => foo.GetSafeSPValue("Category")).ToDictionary(bar => bar.Key); StringDictionary dictCols = GetColumnsForItem(l.Title); Where l is an SPList whose title determines which columns are used. Each SPListItem corresponds to a row of data, which are sorted into separate worksheets based on Category (hence the dictionary). The second line is just a simple StringDictionary that has the column name (A, B, C, etc.) as a key and the corresponding SPListItme field display name as the corresponding value. So for each Category, I enumerate through dictFiles[somekey] to get all the rows in that sheet, and get the particular cell data using SPListItem.Fields[dictCols[colName]]. What I am asking is, is there a quick or concise method, for any one dictFiles[somekey], to retrieve a readout of the longest string in each column provided by dictCols? If it is impossible to get both quickness and conciseness, I can settle for either (since I always have the O(n*m) route of just enumerating the collection and updating an array whenever strCurrent.Length strLongest.Length). For example, if the goal table was the following... Item# Field1 Field2 Field3 1 Oarfish Atmosphere Pretty 2 Raven Radiation Adorable 3 Sunflower Flowers Cute I'd like a function which could cleanly take the collection of items 1, 2, and 3 and output in the correct order... Sunflower, Atmosphere, Adorable Using .NET 3.5 and C# 3.0.

    Read the article

  • How to filter txt file by string with using batch

    - by Antediluvian
    Hello guys I know this kind of problem will be very easy for you but I am total beginner in batch mode. The question is how bat file code should look like to generate a new txt file from specific one . for example . I have report txt Displaying status for license file: 7788@Server01 License Server: server01 License In Use Free ------- ------ ---- Design* 1 6 (user1@host1) 127 server01 7788 4402 Assembly* 0 4 Pro 0 15 AdvSE 2 3 (user2@host2) AdvSE server01 7788 2706 (user3@host3) AdvSE server01 7788 1503 SingleSite_License 1 3 (user4@host4) SingleSite_License server01 7788 2003 Intra_CLIENT_License 1 4 (user2@host2) Intra_CLIENT_License server01 7788 2003 CAD 1 32 ^(user2@host2) CAD server01 7788 501 * = License Extensions - Available only on startup. ^ = Borrowed License. Press any key to continue . . . What I want to have in new file from this one are only lines : SingleSite_License 3 Intra_CLIENT_License 9 but both SingleSite_License and Intra_Client_License should be taken from 1st found string -other are not necessary. report txt can be different and licenses can be showed in different order . if it not possible - other solution can be just only Free value will be written in new txt file - f.e 3 and 9 . so the last string in line which contains specific words thank you for any tips

    Read the article

  • null terminating a string

    - by robUK
    Hello, gcc 4.4.4 c89 just wondering what is the standard way to null terminate a string. i.e. However, when I use the NULL I get the warning message. *dest++ = 0; *dest++ = '\0'; *dest++ = NULL; /* Warning: Assignment takes integer from pointer without a cast */ source code I am using: size_t s_strscpy(char *dest, const char *src, const size_t len) { /* Copy the contents from src to dest */ size_t i = 0; for(i = 0; i < len; i++) *dest++ = *src++; /* Null terminate dest */ *dest++ = 0; return i; } Just another quick question. I deliberately commented out the line that null terminates. However, it still correctly printed out the contents of the dest. The caller of this function would send the length of the string by either included the NULL or not. i.e. strlen(src) + 1 or stlen(src). size_t s_strscpy(char *dest, const char *src, const size_t len) { /* Copy the contents from src to dest */ size_t i = 0; /* Don't copy the null terminator */ for(i = 0; i < len - 1; i++) *dest++ = *src++; /* Don't add the Null terminator */ /* *dest++ = 0; */ return i; } Many thanks for any advice,

    Read the article

  • Convert Virtual Key Code to unicode string

    - by Joshua Weinberg
    I have some code I've been using to get the current keyboard layout and convert a virtual key code into a string. This works great in most situations, but I'm having trouble with some specific cases. The one that brought this to light is the accent key next to the backspace key on german QWERTZ keyboards. http://en.wikipedia.org/wiki/File:KB_Germany.svg That key generates the VK code I'd expect kVK_ANSI_Equal but when using a QWERTZ keyboard layout I get no description back. Its ending up as a dead key because its supposed to be composed with another key. Is there any way to catch these cases and do the proper conversion? My current code is below. TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr); if(keyboardLayout) { UInt32 deadKeyState = 0; UniCharCount maxStringLength = 255; UniCharCount actualStringLength = 0; UniChar unicodeString[maxStringLength]; OSStatus status = UCKeyTranslate(keyboardLayout, keyCode, kUCKeyActionDown, 0, LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, maxStringLength, &actualStringLength, unicodeString); if(actualStringLength > 0 && status == noErr) return [[NSString stringWithCharacters:unicodeString length:(NSInteger)actualStringLength] uppercaseString]; }

    Read the article

  • regex match css class name from single string containing multiple classes

    - by effectica
    I have a long string that contains multiple css classes. With regex I would like to match every class name as I then need to replace these class names like so: <span>CLASSNAME</span> I have tried for hours to come up with a solution and I think I am close however for certain class names I am not able to exclude closing curly brackets from the match. Here is a sample string I have been carrying out testing on: #main .items-Outer p{ font-family:Verdana; color: #000000; font-size: 50px; font-weight: bold; }#footer .footer-inner p.intro{ font-family:Arial; color: #444444; font-size: 30; font-weight: normal; }.genericTxt{ font-family:Courier; color: #444444; font-size: 30; font-weight: normal; } And here is the the regex I came up with so far: ((^(?:.+?)(?:[^{]*))|((?:\})(?:.+?)(?:[^{]*))) Please look at the screenshot I am attaching as it will show more clearly the matches I get. My problem is that I would obviously like to exclude curly brackets from any match.

    Read the article

  • capture text, including tags from string, and then reorder tags with text

    - by Brian
    I have the following text: abcdef<CONVERSION>abcabcabcabc<2007-01-12><name1><2007-01-12>abcabcabcabc<name2><2007-01-11>abcabcabcabc<name3><2007-02-12>abcabcabcabc<name4>abcabcabcabc<2007-03-12><name5><date>abcabcabcabc<name6> I need to use regular expressions in order to clean the above text: The basic extraction rule is: <2007-01-12>abcabcabcabc<name2> I have no problem extracting this pattern. My issue is that within th text I have malformed sequences: If the text doesn't start with a date, and end with a name my extraction fails. For example, the text above may have several mal formed sequences, such as: abcabcabcabc<2007-01-12><name1> Should be: <2007-01-12>abcabcabcabc<name1> Is it possible to have a regular expression that would clean the above, prior to extracting my consistent pattern. In short, i need to find all mal formed patterns, and then take the date tag and put it in front of it, as provided in the example above. Thanks.

    Read the article

  • A better way of getting a data table with various column types into string array

    - by Vlad
    This should be an easy one, looks like I got myself too confused. I get a table from a database, data ranges from varchar to int to Null values. Cheap and dirty way of converting this into a tab-delimited file that I already have is this (shrunken to preserve space, ugliness is kept on par with original): da.Fill(dt) ' da - DataAdapter ' ' dt - DataTable ' Dim lColumns As Long = dt.Columns.Count Dim arrColumns(dt.Columns.Count) As String Dim arrData(dt.Columns.Count) As Object Dim j As Long = 0 Dim arrData(dt.Columns.Count) As Object For i = 0 To dt.Rows.Count - 1 arrData = dt.Rows(i).ItemArray() For j = 0 To arrData.GetUpperBound(0) - 1 arrColumns(j) = arrData(j).ToString Next wrtOutput.WriteLine(String.Join(strFieldDelimiter, arrColumns)) Array.Clear(arrColumns, 0, arrColumns.GetLength(0)) Array.Clear(arrData, 0, arrData.GetLength(0)) Next Not only this is ugly and inefficient, it is also getting on my nerves. Besides, I want, if possible, to avoid the infamous double-loop through the table. I would really appreciate a clean and safe way of rewriting this piece. I like the approach that is used here - especially that is trying to solve the same problem that I have, but it crashes on me when I apply it to my case directly.

    Read the article

  • Ajax return string links not working

    - by Andreas Lympouras
    I have this ajax function: function getSearchResults(e) { var searchString = e.value; /*var x = e.keyCode; var searchString = String.fromCharCode(x);*/ if (searchString == "") { document.getElementById("results").innerHTML = ""; return; } var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("results").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "<%=Page.ResolveUrl("~/template/searchHelper.aspx?searchString=")%>"+searchString, true); xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); //solve any AJAX caching problem(not refreshing) xmlhttp.send(); } and here is when I call it: <input class="text-input" value="SEARCH" id="searchbox" onkeyup="javascript:getSearchResults(this);" maxlength="50" runat="server" /> and all my links in the searchHelper.aspx file(which retruns them as a string) are like this: <a class="item" href='../src/actors.aspx?id=77&name=dasdassss&type=a' > <span class="item">dasdassss</span></a> When I click this link I want my website to go to ../src/actors.aspx?id=77&name=dasdassss&type=a but nothing happens. When I hover over the link, it also shows me where the link is about to redirect! any help?

    Read the article

  • Extracting a number from a 1-word string

    - by Kyle
    In this program I am trying to make, I have an expression (such as "I=23mm", or "H=4V") and I am trying to extract the 23 (or the 4) out of it, so that I can turn it into an integer. The problem I keep running into is that since the expression I am trying to take the numbers out of is 1 word, I cannot use split() or anything. One example I saw but wouldnt work was - I="I=2.7A" [int(s) for s in I.split() if s.isdigit()] This wouldnt work because it only takes the numbers are are delimited by spaces. If there was a number in the word int078vert, it wouldnt extract it. Also, mine doesnt have spaces to delimit. I tried one that looked like this, re.findall("\d+.\d+", "Amps= 1.4 I") but it didnt work either, because the number that is being passed is not always 2 digits. It could be something like 5, or something like 13.6. What code do I need to write so that if I pass a string, such as I="I=2.4A" or I="A=3V" So that I can extract only the number out of this string? (and do operations on it)? There are no spaces or other constant chars that I can delimit by.

    Read the article

  • Parsing a string in c#

    - by Jay
    Hi, Suppose there is an xml file like below: <Instances> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image1.jpg" ImageNumber = "1"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image2.jpg" ImageNumber = "2"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image3.jpg" ImageNumber = "3"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image4.jpg" ImageNumber = "4"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image5.jpg" ImageNumber = "5"/> </Instances> This xml file is read as a string and passed on to a function. This xml file has information about a particular image file. I want to extract the location of all the image files from this string. So whatever is value of "location" filed i need to collect all those value. What is the best way to achieve this in C#. Thanks,

    Read the article

  • I cant put a string in a switch nor an array in a class

    - by TimothyTech
    Okay, im making a pretty big file in my opinion, so i wanted to separate it into several files for cleaner code. so i have my main .cpp file and two header files holding my classes. well the header files dont hold strings, it aboslutely wont budge. i call the library in both my .cpp file and even tried it in my header file. another issue i ran into is using strings to make switches function, reason being if i use integers in a switch if the user inputs a alphabetical character the program goes into an endless loop. string choice; switch (choice) { case "1" : //... break; case "2" : //... break; } and my last issue is when i create an object in a case it gives an error. says cross initialization of object. string choice; switch (choice) { case "1" : Class object; break; case "2" : //... break; }

    Read the article

  • problem with a string's format in c++ while doing tcp communication

    - by james t
    hi, i am building a simple c++ client, i am splitting the info i get from the server to frames, and pass each frame to a function that processes it, i split the frame into lines using Poco::StringTokenizer tokenizer(frame, "\n"); i take the first line of the tokenizer which represents the type of frame StmpCommand command(tokenizer[0]); a StmpCommand is an enum with the different types of messages and the constructor works as follows : StmpCommand(std::string command): commandType_() { bool x=command=="CONNECTED"; std::cout<<x<<std::endl; if ("SUBSCRIBE" == command) commandType_ = SUBSCRIBE; else if ("UNSUBSCRIBE" == command) commandType_ = UNSUBSCRIBE; else if ("SEND" == command) commandType_ = SEND; else if ("BEGIN" == command) commandType_ = BEGIN; else if ("COMMIT" == command) commandType_ = COMMIT; else if ("CONNECT" == command) commandType_ = CONNECT; else if ("MESSAGE" == command) commandType_ = MESSAGE; else if ("RECEIPT" == command) commandType_ = RECEIPT; else if ("CONNECTED" == command) commandType_ = CONNECTED; else if ("DISCONNECT" == command) commandType_ = DISCONNECT; else if ("ERROR" == command) commandType_ = ERROR; else { std::cerr<<"Error in building StmpCommand object, unknown type - "<<command<<std::endl; } } the first frame i am trying to proccess is a CONNECTED frame therefor i try to create a StmpCommand with CONNECTED as the constructor's only argument and for some reason i am getting an : Error in building StmpCommand object, unknown type - CONNECTED i am clearly passing a string containing CONNECTED but i'm guessing there is something else there that isn't allowing the condition else if ("CONNECTED" == command) to hap

    Read the article

  • Storing multiple discarded datas in a single variable using a string accumulator

    - by dan
    For an assignment for my intro to python course, we are to write a program that generates 100 sets of x,y coordinates. X must be a float between -100.0 and 100.0 inclusive, but not 0. Y is Y = ((1/x) * 3070) but if the absolute value of Y is greater than 100, both numbers must be discarded (BUT STORED) and another set generated. The results must be displayed in a table, and then after the table, the discarded results must be shown. The teacher said we should use a "string accumulator" to store the discarded data. This is what I have so far, and I'm stuck at storing the discarded data. # import random.py import random # import math.py import math # define main def main(): x = random.uniform(-100.0, 100.0) while x == 0: x = random.uniform(-100.0, 100.0) y = ((1/x) * 3070) while math.fabs(y) > 100: xDiscarded = yDiscarded = y = ((1/x) * 3070) As you can see, I run into the problem of when abs(y) 100, I'm not too sure how to store the discarded data and let it accumulate every time abs(y) 100. I'm cool with the data being stored as "351.2, 231.1, 152.2" I just don't know how to turn the variable into a string and store it. We haven't learned arrays yet so I can't do that. Any help would be much appreciated. Thanks!

    Read the article

< Previous Page | 175 176 177 178 179 180 181 182 183 184 185 186  | Next Page >