Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 86/269 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • URL protocol handler shell execute problem

    - by Chuck
    Hi, I'm working on a small hobby web site where I'm able to launch a local app with certain arguments based on links. Setting up a protocol wasn't difficult, as described in http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx, but I have one dilemma: Let's say the protocol is: foo:127.0.0.1:1111, so a link like href="foo:127.0.0.1:1111" would launch an app like: bar.exe "%1". Since I don't have any control over bar.exe (if I had, then it would be no problem to just parse it, obviously), I need some help parsing %1. bar.exe will launch correctly if it's run as bar.exe 127.0.0.1:1111, but not if it's run as bar.exe foo:127.0.0.1:1111. So I guess my question is... is there ANY way to tell the registry to pass on not %1, but a trimmed %1? (Thinking in terms of regexp where you have match[0] = all of the matched, match[1] = first capture in the matched text). I can solve it by having a .bat instead of .exe, but as I would like to make it as easy as possible for the user to use, I would LOVE it if I could handle it all stricly in registry. Any help is greatly appreciated! Chuck

    Read the article

  • Using XSLT to Find Nodes Given a Set of Parameters

    - by davecardwell
    Sorry about the title—wasn’t sure how to word it. Basically I have some XML like this: <countries> <country handle="bangladesh"/> <country handle="india"/> <country handle="pakistan"/> </countries> And some XSLT like this (which doesn’t work): <xsl:template match="/countries"> <xsl:param name="popular"/> <xsl:apply-templates select="country[count($popular/country[@handle = current()/@handle]) &gt; 0]" /> </xsl:template> <xsl:template match="/countries/country"> … </xsl:template> I want to pass in a list of popular destinations like this: <popular> <country handle="india"/> <country handle="pakistan"/> </popular> …to the /countries template and have it only operate on the ones in the $popular param. At the moment this simply does nothing. Changing the selector to country[true()] operates on them all, so at least I know the basic structure is right. Any ideas? I think I may be getting confused by what is currently “current()”.

    Read the article

  • get another sequence elements'value in one sequence.

    - by lxusharp
    I have an XML file as below, and I want to transform it with xslt. I want to achieve is: when do the for-each of "s1" elements, I want to get the corresponding "r1"'s "value" attbute value. the xslt I wrote as below, but it does not work, can anyone give a help? thanks. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="html" indent="yes"/> <xsl:template mode="getr1" match="summary" > <xsl:param name="index"/> <xsl:value-of select="r1[$index][@value]"/> </xsl:template> <xsl:template match="/"> <html> <body> <ul> <xsl:for-each select="root/s1"> <xsl:variable name="i" select="position()"/> <li> <xsl:value-of select ="@name"/> : <!--<xsl:apply-templates mode="getr1" select="/root/summary"> <xsl:with-param name="index" select="$i" /> </xsl:apply-templates>--> <!--I want to get the corresponding r1's value according to the index --> <!-- but above code is not work.--> </li> </xsl:for-each> </ul> </body> </html> </xsl:template> </xsl:stylesheet>

    Read the article

  • PHP, MySQL prepared statements - can you use results of execute more than once by calling data_seek(

    - by Carvell Fenton
    Hello, I have a case where I want to use the results of a prepared statement more than once in a nested loop. The outer loop processes the results of another query, and the inner loop is the results of the prepared statement query. So the code would be something like this (just "pseudoish" to demonstrate the concept): // not showing the outer query, it is just a basic SELECT, not prepared statement // we'll call it $outer_query $obj_array = array(); // going to save objects in this $ids = array(18,19,20); // just example id numbers $query = "SELECT field1, field2 FROM table1 WHERE id=?"; $stmt = $db->prepare($query); foreach ($ids as $id) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($var1, $var2); $stmt->store_result(); // I think I need this for data_seek while ($q1 = $outer_query->fetch_object()) { while ($stmt->fetch()) { if ($q1->field1 == $var1) { // looking for a match $obj = new stdClass(); $obj->var1 = $var1; $obj->var2 = $var2; $obj_array[] = $obj; $stmt->data_seek(0); // reset for outer loop break; // found match, so leave inner } } } } The problem I seem to be experiencing is that the values are not getting bound in the variables as I would expect after the first time I use fetch in the inner loop. Specifically, in one example I ran with 3 ids for the foreach, the first id was processed correctly, the second was processed incorrectly (matches were not found in the inner loop even though they existed), and then the third was processed correctly. Is there something wrong with the prepared statment function calls in the sequence I am doing above, or is this an invalid way to use the results of the prepared statement? Thanks.

    Read the article

  • Post Method Not giving Alerts like planned?

    - by Charles
    <form action="" method="post"> <div align="center"><legend>Add a Code</legend> <label for="code"></label> <input type="text" name="code" id="code" maxlength="10" /> <input type='button' onclick= "isAlphanumeric(document.getElementById('code'),'Your Submission Contained Invalid Characters'); isBadPhrase(document.getElementById('code'), 'Please Enter A Correct Friend Code!');" value='Check Field' /> function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isBadPhrase(elem,helperMsg){ var badPhrase=/EPW|ESW|\s/; if (elem.value.match(badPhrase)){ alert(helperMsg); elem.focus(); return false; }else{ return true; } } What is wrong here?

    Read the article

  • Using lambda expressions and linq

    - by Andy
    So I've just started working with linq as well as using lambda expressions. I've run into a small hiccup while trying to get some data that I want. This method should return a list of all projects that are open or in progress from Jira Here's the code public static List<string> getOpenIssuesListByProject(string _projectName) { JiraSoapServiceService jiraSoapService = new JiraSoapServiceService(); string token = jiraSoapService.login(DEFAULT_UN, DEFAULT_PW); string[] keys = { getProjectKey(_projectName) }; RemoteStatus[] statuses = jiraSoapService.getStatuses(token); var desiredStatuses = statuses.Where(x => x.name == "Open" || x.name == "In Progress") .Select(x=>x.id); RemoteIssue[] AllIssues = jiraSoapService.getIssuesFromTextSearchWithProject(token, keys, "", 99); IEnumerable<RemoteIssue> openIssues = AllIssues.Where(x=> { foreach (var v in desiredStatuses) { if (x.status == v) return true; else return false; } return false; }); return openIssues.Select(x => x.key).ToList(); } Right now this only select issues that are "Open", and seems to skip those that are "In Progress". My question: First, why am I only getting the "Open" Issues, and second is there a better way to do this? The reason I get all the statuses first is that the issue only stores that statuses ID, so I get all the statuses, get the ID's that match "Open" and "In Progress", and then match those ID numbers to the issues status field.

    Read the article

  • tomcat resource missing, servlet not running

    - by user2837260
    import javax.servlet.*; import java.io.*; public class MyServlet implements Servlet { public void init(ServletConfig con) {} public void service(ServletRequest req, ServletResponse res) throws IOException,ServletException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); String s="blah"; String s1="blah"; out.println("<html><body>"); if((s.equals(req.getParameter("firstname")))&&(s1.equals(req.getParameter("pwd")))) out.println("passwords match"); else out.println("password and name combo does not match"); out.println("</body></html>"); } public void destroy() {} public ServletConfig getServletConfig() { return null;} public String getServletInfo() { return null;} } this is my java file with the servlet class.its saved with the name MyServlet.java and so is the class file. and here is the xml file: <web-app> <servlet> <servlet-name>demoo</servlet-name> <servlet-class>MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>demoo</servlet-name> <url-pattern>/demo</url-pattern> </servlet-mapping> </web-app> i have made the folder as WEB-INF and then classes... WEB-INF also contains the .xml file but when i try to run the servlet , it says resource not found ps- i am already looking for the servlet with the name :demo localhost:8081/s1/demo* s1 is the war file * a html file in the war file seems to run fine on the server though. *

    Read the article

  • Regex expression is too greedy

    - by alastairs
    I'm writing a regular expression to match data from the IMDb soundtracks data file. My regexes are mostly working, although they are in places slurping too much text into my named groups. Take the following regex for example: "^ Performed by '?(?<performer>.*)('? \(qv\))?$" The performer group includes the string ' (qv) as well as the performer's name. Unfortunately, because the records are not consistently formatted, some performers' names are surrounded by single quotation marks whilst others are not. This means they are optional as far as the regex is concerned. I've tried marking the last group as a greedy group using the ?> group specifier, but this appeared to have no effect on the results. I can improve the results by changing the performer group to match a small range of characters, but this reduces my chances of parsing the name out correctly. Furthermore, if I were to just exclude the apostrophe character, I would then be unable to parse, e.g., band names containing apostrophes, such as Elia's Lonely Friends Band who performed Run For Your Life featured in Resident Evil: Apocalypse.

    Read the article

  • Is there an equivalent for ActiveRecord#find_by equivalent for C#?

    - by Benjamin Manns
    I'm originally a C# developer (as a hobby), but as of late I have been digging into Ruby on Rails and I am really enjoying it. Right now I am building an application in C# and I was wondering if there is any collection implementation for C# that could match (or "semi-match") the find_by method of ActiveRecord. What I am essentially looking for is a list that would hold Rectangles: class Rectangle { public int Width { get; set; } public int Height { get; set; } public String Name { get; set; } } Where I could query this list and find all entries with Height = 10, Width = 20, or name = "Block". This was done with ActiveRecord by doing a call similar to Rectangle.find_by_name('Block'). The only way I can think of doing this in C# is to create my own list implementation and iterate through each item manually checking each item against the criteria. I fear I would be reinventing the wheel (and one of poorer quality). Any input or suggestions is much appreciated.

    Read the article

  • Is it possible to guarantee a unique id for multiple items using the same id variable at a point in

    - by Scarface
    First of all, do not be overwhelmed by the long code, I just put it for reference...I have a function that preg_replaces content and puts it in a jquery dialog box with a matching open-link. For example, if there is a paragraph with two matches, they will be put inside two divs, and a jquery dialog function will be echoed twice; one for each div. While this works for one match, if there are multiple matches, it does not. I am not sure how to distribute unique ids at a point in time for each of the divs and matching dialog open-scripts. Keep in mind, I removed the preg replace function since it kind of complicates the problem. If anyone has any ideas, they will be greatly appreciated. <?php $id=uniqid(); $id2=uniqid(); echo "<div id=\"$id2\"> </div>"; ?> $.ui.dialog.defaults.bgiframe = true; $(function() { $("<?php echo"#$id2"; ?>").dialog({hide: 'clip', modal: true ,width: 600,height: 350,position: 'center', show: 'clip',stack: true,title: 'title', minHeight: 25, minWidth: 100, autoOpen: false}); $('<?php echo"#$id"; ?>').click(function() { $('<?php echo"#$id2"; ?>').dialog('open'); }) .hover( function(){ $(this).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); } ).mousedown(function(){ $(this).addClass("ui-state-active"); }) .mouseup(function(){ $(this).removeClass("ui-state-active"); }); });

    Read the article

  • Are .NET's regular expressions Turing complete?

    - by Robert
    Regular expressions are often pointed to as the classical example of a language that is not Turning complete. For example "regular expressions" is given in as the answer to this SO question looking for languages that are not Turing complete. In my, perhaps somewhat basic, understanding of the notion of Turning completeness, this means that regular expressions cannot be used check for patterns that are "balanced". Balanced meaning have an equal number of opening characters as closing characters. This is because to do this would require you to have some kind of state, to allow you to match the opening and closing characters. However the .NET implementation of regular expressions introduces the notion of a balanced group. This construct is designed to let you backtrack and see if a previous group was matched. This means that a .NET regular expressions: ^(?<p>a)*(?<-p>b)*(?(p)(?!))$ Could match a pattern that: ab aabb aaabbb aaaabbbb ... etc. ... Does this means .NET's regular expressions are Turing complete? Or are there other things that are missing that would be required for the language to be Turing complete?

    Read the article

  • How does one implement storage/retrieval of smart-search/mailbox features?

    - by humble_coder
    Hi All, I have a question regarding implementation of smart-search features. For example, consider something like "smart mailboxes" in various email applications. Let's assume you have your data (emails) stored in a database and, depending on the field for which the query will be created, you present different options to the end user. At the moment let's assume the Subject, Verb, Object approach… For instance, say you have the following: SUBJECTs: message, to_address, from_address, subject, date_received VERBs: contains, does_not_contain, is_equal_to, greater_than, less_than OBJECTs: ??????? Now, in case it isn't clear, I want a table structure (although I'm not opposed to an external XMLesque file of some sort) to store (and later retrieve/present) my criteria for smart searches/mailboxes for later use. As an example, using SVO I could easily store then reconstruct a query for "date between two dates" -- simply use "date greater than" AND "date less than". However, what if, in the same smart search, I wanted a "between" OR'ed with another criterion? You can see that it might get out of hand -- not necessarily in the query creation (as that is rather simplistic), but in the option presentation and storage mechanism. Perhaps I need to think more on a more granular level. Perhaps I need to simply allow the user to select AND or OR for each entry independently instead of making it an ALL OR NOTHING type smart search (i.e. instead of MATCH ALL or MATCH ANY, I need to simply allow them to select -- I just don't want it to turn into a Hydra). Any input would be most appreciated. My apologies if the question is a bit incoherent. It is late, and I my brain is toast. Best.

    Read the article

  • Overloading generic implicit conversions

    - by raichoo
    Hi I'm having a little scala (version 2.8.0RC1) problem with implicit conversions. Whenever importing more than one implicit conversion the first one gets shadowed. Here is the code where the problem shows up: // containers class Maybe[T] case class Nothing[T]() extends Maybe[T] case class Just[T](value: T) extends Maybe[T] case class Value[T](value: T) trait Monad[C[_]] { def >>=[A, B](a: C[A], f: A => C[B]): C[B] def pure[A](a: A): C[A] } // implicit converter trait Extender[C[_]] { class Wrapper[A](c: C[A]) { def >>=[B](f: A => C[B])(implicit m: Monad[C]): C[B] = { m >>= (c, f) } def >>[B](b: C[B])(implicit m: Monad[C]): C[B] = { m >>= (c, { (x: A) => b } ) } } implicit def extendToMonad[A](c: C[A]) = new Wrapper[A](c) } // instance maybe object maybemonad extends Extender[Maybe] { implicit object MaybeMonad extends Monad[Maybe] { override def >>=[A, B](a: Maybe[A], f: A => Maybe[B]): Maybe[B] = { a match { case Just(x) => f(x) case Nothing() => Nothing() } } override def pure[A](a: A): Maybe[A] = Just(a) } } // instance value object identitymonad extends Extender[Value] { implicit object IdentityMonad extends Monad[Value] { override def >>=[A, B](a: Value[A], f: A => Value[B]): Value[B] = { a match { case Value(x) => f(x) } } override def pure[A](a: A): Value[A] = Value(a) } } import maybemonad._ //import identitymonad._ object Main { def main(args: Array[String]): Unit = { println(Just(1) >>= { (x: Int) => MaybeMonad.pure(x) }) } } When uncommenting the second import statement everything goes wrong since the first "extendToMonad" is shadowed. However, this one works: object Main { implicit def foo(a: Int) = new { def foobar(): Unit = { println("Foobar") } } implicit def foo(a: String) = new { def foobar(): Unit = { println(a) } } def main(args: Array[String]): Unit = { 1 foobar() "bla" foobar() } } So, where is the catch? What am I missing? Regards, raichoo

    Read the article

  • Refining Search Results [PHP/MySQL]

    - by Dae
    I'm creating a set of search panes that allow users to tweak their results set after submitting a query. We pull commonly occurring values in certain fields from the results and display them in order of their popularity - you've all seen this sort of thing on eBay. So, if a lot of rows in our results were created in 2009, we'll be able to click "2009" and see only rows created in that year. What in your opinion is the most efficient way of applying these filters? My working solution was to discard entries from the results that didn't match the extra arguments, like: while($row = mysql_fetch_assoc($query)) { foreach($_GET as $key => $val) { if($val !== $row[$key]) { continue 2; } } // Output... } This method should hopefully only query the database once in effect, as adding filters doesn't change the query - MySQL can cache and reuse one data set. On the downside it makes pagination a bit of a headache. The obvious alternative would be to build any additional criteria into the initial query, something like: $sql = "SELECT * FROM tbl MATCH (title, description) AGAINST ('$search_term')"; foreach($_GET as $key => $var) { $sql .= " AND ".$key." = ".$var; } Are there good reasons to do this instead? Or are there better options altogether? Maybe a temporary table? Any thoughts much appreciated!

    Read the article

  • ASP.NET MVC 2 user input to SQL 2008 Database problems

    - by Rob
    After my publish in VS2010 the entire website loads and pulls data from the database perfectly. I can even create new users through the site with the correct key code, given out to who needs access. I have two connection strings in my web.config file The first: <add xdt:Transform="SetAttributes" xdt:Locator="Match(name)" name="EveModelContainer" connectionString="metadata=res://*/Models.EdmModel.EveModel.csdl|res://*/Models.EdmModel.EveModel.ssdl|res://*/Models.EdmModel.EveModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=fleet;Persist Security Info=True;User ID=fleet;Password=****&quot;" providerName="System.Data.EntityClient" /> The second: <add xdt:Transform="SetAttributes" xdt:Locator="Match(name)" name="ApplicationServices" connectionString="Data Source=localhost;Initial Catalog=fleet;Persist Security Info=True;User ID=fleet;Password=****;MultipleActiveResultSets=True" /> The first one is the one that is needed to post data with the main application, EveModelContainer. Everything else is pulled using the standard ApplicationServices connection. Do you see anything wrong with my connectionstring? I'm at a complete loss here. The site works perfectly on my friends server and not on mine... Could it be a provider issue? And if I go to iis 7's manager console, and click .net users I get a pop up message saying the custom provider isn't a trusted provider do I want to allow it to run at a higher trust level. I'm at the point where I think its either my string or this trusted provider error... but I have no clue how to add to the trusted provider list... Thank you in advance!!!

    Read the article

  • perl - converting a date into a string

    - by Jason
    I need to convert a date to a string, the date is entered as 07/04/2010 and should then read July 4th 2010. It should also be able to be entered using singe digits instead of double (7 instead of 07, and it needs to add the 20 to the year if the user enters only /10) This is what I have so far - #!/usr/bin/perl use CGI qw(:standard); use strict; #declare variables my ($date, $month, $day, $year); my @months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); #assign input item to variable $date = param('Date'); #break date apart $date =~ /([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,2}|20[0-9]{2,2})/; $month = $1; $day = $2; $year = $3; unless($year =~ /20[0-9]{2,2}/){ $year = "20".$year; } $date = $months[int($1)]." ".$day.", ".$year; #display date print "<HTML><HEAD><TITLE>The Date</TITLE></HEAD>\n"; print "<BODY>\n"; print "The date is: $date\n"; print "</BODY></HTML>\n"; However I keep getting errors Use of uninitialized value in pattern match (m//) at c08ex6.cgi line 14. Use of uninitialized value in pattern match (m//) at c08ex6.cgi line 18. Use of uninitialized value in concatenation (.) or string at c08ex6.cgi line 19. Use of uninitialized value in int at c08ex6.cgi line 21. Use of uninitialized value in concatenation (.) or string at c08ex6.cgi line 21.

    Read the article

  • SQL indexes for "not equal" searches

    - by bortzmeyer
    The SQL index allows to find quickly a string which matches my query. Now, I have to search in a big table the strings which do not match. Of course, the normal index does not help and I have to do a slow sequential scan: essais=> \d phone_idx Index "public.phone_idx" Column | Type --------+------ phone | text btree, for table "public.phonespersons" essais=> EXPLAIN SELECT person FROM PhonesPersons WHERE phone = '+33 1234567'; QUERY PLAN ------------------------------------------------------------------------------- Index Scan using phone_idx on phonespersons (cost=0.00..8.41 rows=1 width=4) Index Cond: (phone = '+33 1234567'::text) (2 rows) essais=> EXPLAIN SELECT person FROM PhonesPersons WHERE phone != '+33 1234567'; QUERY PLAN ---------------------------------------------------------------------- Seq Scan on phonespersons (cost=0.00..18621.00 rows=999999 width=4) Filter: (phone <> '+33 1234567'::text) (2 rows) I understand (see Mark Byers' very good explanations) that PostgreSQL can decide not to use an index when it sees that a sequential scan would be faster (for instance if almost all the tuples match). But, here, "not equal" searches are really slower. Any way to make these "is not equal to" searches faster? Here is another example, to address Mark Byers' excellent remarks. The index is used for the '=' query (which returns the vast majority of tuples) but not for the '!=' query: essais=> EXPLAIN ANALYZE SELECT person FROM EmailsPersons WHERE tld(email) = 'fr'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ Index Scan using tld_idx on emailspersons (cost=0.25..4010.79 rows=97033 width=4) (actual time=0.137..261.123 rows=97110 loops=1) Index Cond: (tld(email) = 'fr'::text) Total runtime: 444.800 ms (3 rows) essais=> EXPLAIN ANALYZE SELECT person FROM EmailsPersons WHERE tld(email) != 'fr'; QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Seq Scan on emailspersons (cost=0.00..27129.00 rows=2967 width=4) (actual time=1.004..1031.224 rows=2890 loops=1) Filter: (tld(email) <> 'fr'::text) Total runtime: 1037.278 ms (3 rows) DBMS is PostgreSQL 8.3 (but I can upgrade to 8.4).

    Read the article

  • How to speed-up python nested loop?

    - by erich
    I'm performing a nested loop in python that is included below. This serves as a basic way of searching through existing financial time series and looking for periods in the time series that match certain characteristics. In this case there are two separate, equally sized, arrays representing the 'close' (i.e. the price of an asset) and the 'volume' (i.e. the amount of the asset that was exchanged over the period). For each period in time I would like to look forward at all future intervals with lengths between 1 and INTERVAL_LENGTH and see if any of those intervals have characteristics that match my search (in this case the ratio of the close values is greater than 1.0001 and less than 1.5 and the summed volume is greater than 100). My understanding is that one of the major reasons for the speedup when using NumPy is that the interpreter doesn't need to type-check the operands each time it evaluates something so long as you're operating on the array as a whole (e.g. numpy_array * 2), but obviously the code below is not taking advantage of that. Is there a way to replace the internal loop with some kind of window function which could result in a speedup, or any other way using numpy/scipy to speed this up substantially in native python? Alternatively, is there a better way to do this in general (e.g. will it be much faster to write this loop in C++ and use weave)? ARRAY_LENGTH = 500000 INTERVAL_LENGTH = 15 close = np.array( xrange(ARRAY_LENGTH) ) volume = np.array( xrange(ARRAY_LENGTH) ) close, volume = close.astype('float64'), volume.astype('float64') results = [] for i in xrange(len(close) - INTERVAL_LENGTH): for j in xrange(i+1, i+INTERVAL_LENGTH): ret = close[j] / close[i] vol = sum( volume[i+1:j+1] ) if ret > 1.0001 and ret < 1.5 and vol > 100: results.append( [i, j, ret, vol] ) print results

    Read the article

  • List files with two dots in their names using java regular expressions

    - by Nivas
    I was trying to match files in a directory that had two dots in their name, something like theme.default.properties I thought the pattern .\\..\\.. should be the required pattern [. matches any character and \. matches a dot] but it matches both oneTwo.txt and theme.default.properties I tried the following: [resources/themes has two files oneTwo.txt and theme.default.properties] 1. public static void loadThemes() { File themeDirectory = new File("resources/themes"); if(themeDirectory.exists()) { File[] themeFiles = themeDirectory.listFiles(); for(File themeFile : themeFiles) { if(themeFile.getName().matches(".\\..\\..")); { System.out.println(themeFile.getName()); } } } } This prints nothing and the following File[] themeFiles = themeDirectory.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.matches(".\\..\\.."); } }); for (File file : themeFiles) { System.out.println(file.getName()); } prints both oneTwo.txt theme.default.properties I am unable to find why these two give different results and which pattern I should be using to match two dots... Can someone help?

    Read the article

  • Arrays not matching correctly

    - by Nick Gibson
    userAnswer[] holds the string of the answer the user types in and is comparing it to answers[] to see if they match up and then spits out correct or wrong. j is equal to the question number. So if j was question 6, answers[j] should refer to answers[6] right? Then userAnswer[6] should compare to answers[6] and match if its correct. But its giving me wrong answers and displaying the answer I typed as correct. int abc, loopCount = 100; int j = quesNum, overValue, forLoop = 100; for (int loop = 1; loop < loopCount; loop++) { aa = r.nextInt(10+1); abc = (int) aa; String[] userAnswer = new String[x]; JOptionPane.showMessageDialog(null,abc); if(abc < x) { userAnswer[j] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]); if(userAnswer[j].equals(answers[j])) { JOptionPane.showMessageDialog(null,"Correct. \nThe Correct Answer is "+answers[abc]); } else { JOptionPane.showMessageDialog(null,"Wrong. \n The Correct Answer is "+answers[abc]); }//else }//if }//for

    Read the article

  • figuring out which field to look for a value in with SQL and perl

    - by Micah
    I'm not too good with SQL and I know there's probably a much more efficient way to accomplish what I'm doing here, so any help would be much appreciated. Thanks in advance for your input! I'm writing a short program for the local school high school. At this school, juniors and seniors who have driver's licenses and cars can opt to drive to school rather than ride the bus. Each driver is assigned exactly one space, and their DLN is used as the primary key of the driver's table. Makes, models, and colors of cars are stored in a separate cars table, related to the drivers table by the License plate number field. My idea is to have a single search box on the main GUI of the program where the school secretary can type in who/what she's looking for and pull up a list of results. Thing is, she could be typing a license plate number, a car color, make, and model, someone driver's name, some student driver's DLN, or a space number. As the programmer, I don't know what exactly she's looking for, so a couple of options come to mind for me to build to be certain I check everywhere for a match: 1) preform a couple of SELECT * FROM [tablename] SQL statements, one per table and cram the results into arrays in my program, then search across the arrays one element at a time with regex, looking for a matched pattern similar to the search term, and if I find one, add the entire record that had a match in it to a results array to display on screen at the end of the search. 2) take whatever she's looking for into the program as a scaler and prepare multiple select statements around it, such as SELECT * FROM DRIVERS WHERE DLN = $Search_Variable SELECT * FROM DRIVERS WHERE First_Name = $Search_Variable SELECT * FROM CARS WHERE LICENSE = $Search_Variable and so on for each attribute of each table, sticking the results into a results array to show on screen when the search is done. Is there a cleaner way to go about this lookup without having to make her specify exactly what she's looking for? Possibly some kind of SQL statement I've never seen before?

    Read the article

  • import csv file/excel into sql database asp.net

    - by kiev
    Hi everyone! I am starting a project with asp.net visual studio 2008 / SQL 2000 (2005 in future) using c#. The tricky part for me is that the existing DB schema changes often and the import files columns will all have to me matched up with the existing db schema since they may not be one to one match on column names. (There is a lookup table that provides the tables schema with column names I will use) I am exploring different ways to approach this, and need some expert advice. Is there any existing controls or frameworks that I can leverage to do any of this? So far I explored FileUpload .NET control, as well as some 3rd party upload controls to accomplish the upload such as SlickUpload but the files uploaded should be < 500mb Next part is reading of my csv /excel and parsing it for display to the user so they can match it with our db schema. I saw CSVReader and others but for excel its more difficult since I will need to support different versions. Essentially The user performing this import will insert and/or update several tables from this import file. There are other more advance requirements like record matching but and preview of the import records, but I wish to get through understanding how to do this first. Update: I ended up using csvReader with LumenWorks.Framework for uploading the csv files.

    Read the article

  • PHP - dynamic page via subdomain

    - by Phil Jackson
    Hi, im creating profile pages based on a subdomains using the wildcard DNS setting. Problem being, if the subdomain is incorrect, I want it to redirect to the same page but without the subdomain infront ie; if ( preg_match('/^(www\.)?([^.]+)\.domainname\.co.uk$/', $_SERVER['HTTP_HOST'], $match)) { $DISPLAY_NAME = $match[2]; $query = "SELECT * FROM `" . ACCOUNT_TABLE . "` WHERE DISPLAY_NAME = '$DISPLAY_NAME' AND ACCOUNT_TYPE = 'premium_account'"; $q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() ); if( mysql_num_rows( $q ) != 0 ) { }else{ mysql_close( $CON ); header("location: http://www.domainname.co.uk"); exit; } } I get a browser error: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. I think its because when using header("location: http://www.domainname.co.uk"); it still puts the sub domain infront i.e. ; header("location: http://www.sub.domainname.co.uk"); Does anyone know how to sort this and/or what is the problem. Regards, Phil

    Read the article

  • string comparision and counting the key in target [closed]

    - by mesun
    Suppose we want to count the number of times that a key string appears in a target string. We are going to create two different functions to accomplish this task: one iterative, and one recursive. For both functions, you can rely on Python's find function - you should read up on its specifications to see how to provide optional arguments to start the search for a match at a location other than the beginning of the string. For example, find("atgacatgcacaagtatgcat","atgc") #returns the value 5, while find("atgacatgcacaagtatgcat","atgc",6) #returns the value 15, meaning that by starting the search at index 6, #the next match is found at location 15. For the recursive version, you will want to think about how to use your function on a smaller version of the same problem (e.g., on a smaller target string) and then how to combine the result of that computation to solve the original problem. For example, given you can find the first instance of a key string in a target string, how would you combine that result with invocation of the same function on a smaller target string? You may find the string slicing operation useful in getting substrings of string.

    Read the article

  • HTML, CSS: overbar matching square root symbol

    - by Pindatjuh
    Is there a way in HTML and/or CSS to do the following, but then correctly: √¯¯¯¯¯¯φ·(2π−γ) Such that there is an overbar above the expression, which neatly aligns with the &radic;? I know there is the Unicode &macr;, that looks like the overbar I need (as used in the above example, though as you can see – it doesn't align well with the root symbol). The solution I'm looking for works at least for one standard font, on most sizes, and all modern browsers. I can't use images; I'd like to have a pure HTML4/CSS way, without client scripting. Here is my current code, thank you Matthew Jones (+1) for the text-decoration: overline! Still some problems <div style="font-family: Georgia; font-size: 200%"> <span style="vertical-align: -15%;">&radic;</span><span style="text-decoration: overline;">&nbsp;x&nbsp;+&nbsp;1&nbsp;</span> </div> The line doesn't match the &radic; because I lowered it with 15% baseline height. (Because the default placement is not nice) The line thickness doesn't match the thickness of the &radic;. Thanks!

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >