Search Results

Search found 2490 results on 100 pages for 'matching'.

Page 12/100 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Novel fitness measure for evolutionary image matching simulation

    - by Nick Johnson
    I'm sure many people have already seen demos of using genetic algorithms to generate an image that matches a sample image. You start off with noise, and gradually it comes to resemble the target image more and more closely, until you have a more-or-less exact duplicate. All of the examples I've seen, however, use a fairly straightforward pixel-by-pixel comparison, resulting in a fairly predictable 'fade in' of the final image. What I'm looking for is something more novel: A fitness measure that comes closer to what we see as 'similar' than the naive approach. I don't have a specific result in mind - I'm just looking for something more 'interesting' than the default. Suggestions?

    Read the article

  • Regex matching very slow

    - by Ali Lown
    I am trying to parse a PDF to extract the text from it (please don't suggest any libraries to do this, as this is part of learning the format). I have already handled deflating it to put it in the alphanumeric format. I now need to extract the text from the text blocks. So, my current pattern is "BT.*?((.*?)).*?ET" (with DOTMATCHALL set) to match something like: BT /F13 12 Tf 288 720 Td (ABC) Tj ET The only bit I want is the text ABC in the brackets. The above pattern works, but is really slow, I assume it is because the regex library is failing to match the pattern that matches the text between BT and the (ABC) many times. The regex is pre-compiled in an attempt to speed it up, but it seems negligible. How may I speed this up?

    Read the article

  • MySQL REGEXP: matching blank entries

    - by Erwin Paglinawan
    Hi, I have this SQL condition that is supposed to retrieve all rows that satisfy the given regexp condition: country REGEXP ('^(USA|Italy|France)$') However, I need to add a pattern for retrieving all blank country values. Currently I am using this condition country REGEXP ('^(USA|Italy|France)$') OR country = "" How can achieve the same effect without having to include the OR clause? Thanks, Erwin

    Read the article

  • Exact matching of strings in SPARQL?

    - by Taz
    I have this query. It match anything which has "South in its Name". But I only want the one whose foaf:name exactly matches "South" SELECT Distinct ?TypeLabel Where { ?a foaf:name "South". ?a rdf:type ?Type. ?Type rdfs:label ?TypeLabel. }

    Read the article

  • Perl regex matching output from `w -hs` command

    - by Bushman
    I'm trying to write a Perl script that will work better with KDE's kwrited, which, as far as I can tell, is connected to a pts and puts every line it receives through the KDE system tray notifications, with the title "KDE write daemon". Unfortunately, it makes a separate notification for each and every line, so it spams up the system tray with multiline messages on regular old write, and for some reason it cuts off the entire last line of the message when using wall (One-line messages are also goners.). I was also hoping to make it so that it could broadcast across a LAN with thick clients. Before starting on that (which would require ssh, of course), I tried to make an ssh-less version to make sure it works. Unfortunately, it doesn't. perl ./write.pl "Testing 1 2 3" where the following is the contents of ./write.pl: #!/usr/bin/perl use strict; use warnings; my $message = ""; my $device = ""; my $possibledevice = '`w -hs | grep "/usr/bin/kwrited"`'; #Where is kwrited? $possibledevice =~ s/^[^\t][\t]//; $possibledevice =~ s/[\t][^\t][\t ]\/usr\/bin\/kwrited$//; $possibledevice = '/dev/'.$possibledevice; unless ($possibledevice eq "") { $device = $possibledevice; } if ($ARGV[0] ne "") { $message = $ARGV[0]; $device = $ARGV[1]; } else { $device = $ARGV[0] unless $ARGV[0] eq ""; while (<STDIN>) { chomp; $message .= <STDIN>; } } if ($message ne "") { system "echo \'$message\' > $device"; } else { print "Error: empty message" } produces the following error: $ perl write.pl "Testing 1 2 3" Use of uninitialized value $device in concatenation (.) or string at write.pl line 29. sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `echo 'foo' > ' Somehow, the regular expressions and/or the backtick escape in processing $possibledevice are not working properly, because where kwrited is connected to /dev/pts/0, the following works perfectly: $ perl write.pl "Testing 1 2 3" /dev/pts/0

    Read the article

  • Matching n parentheses in perl regex

    - by coding_hero
    Hi, I've got some data that I'm parsing in Perl, and will be adding more and more differently formatted data in the near future. What I would like to do is write an easy-to-use function, that I could pass a string and a regex to, and it would return anything in parentheses. It would work something like this (pseudocode): sub parse { $data = shift; $regex = shift; $data =~ eval ("m/$regex/") foreach $x ($1...$n) { push (@ra, $x); } return \@ra; } Then, I could call it like this: @subs = parse ($data, '^"([0-9]+)",([^:]*):(\W+):([A-Z]{3}[0-9]{5}),ID=([0-9]+)'); As you can see, there's a couple of issues with this code. I don't know if the eval would work, the 'foreach' definitely wouldn't work, and without knowing how many parentheses there are, I don't know how many times to loop. This is too complicated for split, so if there's another function or possibility that I'm overlooking, let me know. Thanks for your help!

    Read the article

  • Matching a date in perl

    - by Zerobu
    Hello, I want to match a date in the format day/month/year. where day is two digits month is two digits and year is four digits. Also, I want to check see if it is a valid date, for example knows when is leap year, and know which month has 30days, 31days and 28, or 29 days for Februrary.

    Read the article

  • php regex word boundary matching in utf-8

    - by dontomaso
    Hi, I have the following php code in a utf-8 php file: var_dump(setlocale(LC_CTYPE, 'de_DE.utf8', 'German_Germany.utf-8', 'de_DE', 'german')); var_dump(mb_internal_encoding()); var_dump(mb_internal_encoding('utf-8')); var_dump(mb_internal_encoding()); var_dump(mb_regex_encoding()); var_dump(mb_regex_encoding('utf-8')); var_dump(mb_regex_encoding()); var_dump(preg_replace('/\bweiß\b/iu', 'weiss', 'weißbier')); I would like the last regex to replace only full words and not parts of words. On my windows computer, it returns: string 'German_Germany.1252' (length=19) string 'ISO-8859-1' (length=10) boolean true string 'UTF-8' (length=5) string 'EUC-JP' (length=6) boolean true string 'UTF-8' (length=5) string 'weißbier' (length=9) On the webserver (linux), I get: string(10) "de_DE.utf8" string(10) "ISO-8859-1" bool(true) string(5) "UTF-8" string(10) "ISO-8859-1" bool(true) string(5) "UTF-8" string(9) "weissbier" Thus, the regex works as I expected on windows but not on linux. So the main question is, how should I write my regex to only match at word boundaries? A secondary questions is how I can let windows know that I want to use utf-8 in my php application.

    Read the article

  • PHP - Counting matching arrays in array

    - by Sergio
    hi there, I have an array structure that looks like this: Array ( [0] => Array ( [type] => image [data] => Array ( [id] => 1 [alias] => test [caption] => no caption [width] => 200 [height] => 200 ) ) [1] => Array ( [type] => image [data] => Array ( [id] => 2 [alias] => test2 [caption] => hello there [width] => 150 [height] => 150 ) ) ) My question is, how can I get a count of the number of embedded arrays that have their type set as image (or anything else for that matter)? In practise this value can vary. So, the above array would give me an answer of 2. Thanks

    Read the article

  • weighted matching algorithm in Perl

    - by srk
    Problem : We have equal number of men and women.each men has a preference score toward each woman. So do the woman for each man. each of the men and women have certain interests. Based on the interest we calculate the preference scores. So initially we have an input in a file having x columns. First column is the person(men/woman) id. id are nothing but 0.. n numbers.(first half are men and next half woman) the remaining x-1 columns will have the interests. these are integers too. now using this n by x-1 matrix... we have come up with a n by n/2 matrix. the new matrix has all men and woman as their rows and scores for opposite sex in columns. We have to sort the scores in descending order, also we need to know the id of person related to the scores after sorting. So here i wanted to use hash table. once we get the scores we need to make up pairs.. for which we need to follow some rules. My trouble is with the second matrix of n by n/2 that needs to give information of which man/woman has how much preference on a woman/man. I need these scores sorted so that i know who is the first preferred woman/man, 2nd preferred and so on for a man/woman. I hope to get good suggestions on the data structures i use.. I prefer php or perl. Thank you in advance

    Read the article

  • Regex matching into multiple groups per line?

    - by dmose
    I'm trying to come up with a regex to be able to parse the following type of strings into groups. <link rel="alternate" type="application/rss+xml" title="[!PageTitle!]" href="[!SiteRoot!]/feed.xml" /> My regular expression is: \[\!(.+)\!\] The problem with this expression is that it seems to pull it all into 1 group: Found 1 match: "[!PageTitle!]" href="[!SiteRoot!]" has 1 group: 1. "PageTitle!]" href="[!SiteRoot" I want dont want the regex to continue...am I missing a boundary? Ideally I want it to find 2 groups, [!PageTitle!] and [!SiteRoot!]

    Read the article

  • WPF - Setting ComboBox.SelectedItem in XAML based on matching object

    - by Andy T
    Hi, so, I have templated combobox that is basically acting as a simple colour palette. It is populated with a list of SolidColorBrush objects. Fine. Now, I have some data that holds the hex value of the current colour. I have a converter that converts the hex into a SolidColorBrush. Also fine. Now, I want to set the SelectedItem property of the combobox based on the colour from my datasource. Since my combo is populated with objects of type SolidColourBrush, and my binding converter is returning a SolidColorBrush, I assumed it would be as simple as saying: SelectedItem="{Binding Color, Converter={StaticResource StringToBrush}}" However... it doesn't work :( I've tested that the binding is working behind the scenes by using the exact same value for the Background property of the combobox. It works fine. So, clearly I can't just say SelectedItem = [something] where that [something] is basically an object equal to the item I want to be selected. What is the right way to do this? Surely it's possible in a XAML-only styley using binding, and I don't have to do some nasty C# iterating through all items in the combobox trying to find a match (that seems awfully old-school)...? Any help appreciated. Many thanks! AT

    Read the article

  • Last matching symbol in Regex

    - by Menda
    I couldn't find a more descriptive title, but here there is an example: import re m = re.search(r"\((?P<remixer>.+) (Remix)\)", "Title (Menda Remix)") m.group("remixer") # returns 'Menda' OK m = re.search(r"\((?P<remixer>.+) (Remix)\)", "Title (Blabla) (Menda Remix)") m.group("remixer") # returns 'Blabla) (Menda' FAIL This regex finds the first parenthesis, and I would like to match the last parenthesis for always getting 'Menda'. I've made a workaround to this using extra functions, but I would like a cleaner and a more consistent way using the same regex. Thanks a lot guys.

    Read the article

  • matching files with regular expressions

    - by Javier
    Dear all, I have an input file with a list of movies (Note that there might be some repeated entries): American_beauty__1h56mn38s_ As_Good_As_It_Gets As_Good_As_It_Gets _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ Capote_EN_DVDRiP_XViD-GeT-AW _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ I would to find the corresponding match (line number) from another reference file for each of the entries in the first file: American beauty.(1h56mn38s) As Good As It Gets Capote.EN.DVDRiP.XViD-GeT-AW [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) Quills (2000)(7.4) The desired output would be something like (Reference Movie + Line number from the Reference File): American beauty.(1h56mn38s) 1 As Good As It Gets 2 As Good As It Gets 2 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Capote.EN.DVDRiP.XViD-GeT-AW 3 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Basically, the difference between the entries in both files is that some characters such as: blank spaces, parenthesis, points, etc. have been replaced by underscores. Does anybody could shed some light on it? Best wishes, Javier

    Read the article

  • Xpath to get the 2nd url with the matching text in the href tag

    - by Blankman
    A html page has paging links, 1 set at the top of the page and another on the bottom of the page. Using HtmlUnit, I am currently getting the HtmlAnchor on the page using getByAnchorText("1"); There is a problem in some of the links on the top, so I want to reference the bottom links using XPath. nextPageAnchor = (HtmlAnchor) page.getByXPath(""); How can I reference the 2nd link on the page, with using xpath? I need to reference the link using the AnchorText, so a link like: <a href="....">33</a> The href has random text, and is a javascript function so I have no idea what it will be. Is this possible with xpath?

    Read the article

  • Regex - Ignore lines with matching text

    - by codem
    I need the RegEx command to get all the lines which DO NOT have the job name containing "filewatch". Any help will be greatly appreciated! Thanks. STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-05-ftpfilewatcher STATUS: FAILURE JOB: i3-cur-atmrec-pd-TD_FTP_Forecast_File_Del_M_Su ALARM: JOBFAILURE JOB: i3-cur-atmrec-pd-TD_FTP_Forecast_File_Del_M_Su STATUS: FAILURE JOB: i3-sss-system-heartbeat ALARM: JOBFAILURE JOB: i3-sss-system-heartbeat STATUS: FAILURE JOB: i3-chq-cspo-pd-batch-daily-renametable-fileok STATUS: FAILURE JOB: i3-chq-cspo-pd-batch-daily-renametable-file ALARM: JOBFAILURE JOB: i3-chq-cspo-pd-batch-daily-renametable-fileok ALARM: JOBFAILURE JOB: i3-chq-cspo-pd-batch-daily-renametable-file STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-35-filewatcher STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-05-ftpfilewatcher STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-35-filewatcher STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-05-ftpfilewatcher

    Read the article

  • PCRE/PHP regex not matching last "item"

    - by superbarney
    Here's a regex that I've cobbled up: /(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s(\-{76})/is and here's the text I will be parsing: http://p.linode.com/7015 and here's the replacement for the matched text: <item>\n\t<title>$2</title>\n\t<pubDate>$pubDate</pubDate>\n\t<description>$4</description>\n\t<link>$5</link>\n</item>\n\n I have almost come up with a regex needed to parse a block of text into RSS 2.0 XML markup. I've tested it with RegExr and RegexBuddy and it works perfectly except for the last "item" where there is no line breaks after the link (Line 269). In short, the problem is the "iProperty" article in the text is not matched. Any regex gurus willing to help me troubleshoot what's wrong? I've tried /(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s*(\-{76})/is Here's the output that I get: http://p.linode.com/7016 but that didn't work as I expected (i.e. a newline would be optional). Thanks!

    Read the article

  • Rails uniqueness constraint and matching db unique index for null column

    - by Dave
    I have the following in my migration file def self.up create_table :payment_agreements do |t| t.boolean :automatic, :default => true, :null => false t.string :payment_trigger_on_order t.references :supplier t.references :seller t.references :product t.timestamps end end I want to ensure that if a product_id is specified it is unique but I also want to allow null so I have the following in my model: validates :product_id, :uniqueness => true, :allow_nil => true Works great but I should then add an index to the migration file add_index :payment_agreements, :product_id, :unique => true Obviously this will throw an exception when two null values are inserted for product_id. I could just simply omit the index in the migration but then there's the chance that I'll get two PaymentAgreements with the same product_id as shown here: Concurrency and integrity My question is what is the best/most common way to deal with this problem

    Read the article

  • Matching a value to JSON array values in jquery

    - by chrism
    I have a JSON array that looks like this: ['Monkey','Cheetah','Elephant','Lizard','Spider'] I also have a text input. I want to test whether the value of the input upon 'blur' is also in the array and if it is do something. Knowing a bit of python I tried something like this: var existing_animals = ['Monkey','Cheetah','Elephant','Lizard','Spider'] $('input').blur(function() { user_animal = $(this).val() if (user_animal in existing_animals) { alert('Animal already exists!') } }); So, how rookie is my mistake?

    Read the article

  • java.util.regex.* Recursive matching

    - by amit.bhayani
    Hi Guys, I have been using the java.util.regex.* classes for Regular Expression in Java and all good so far. But today I have a different requirement. For example consider the pattern to be "aabb". Now if the input String is aa it will definitely not match, however there is still possibility that if I append bb it becomes aabb and it matches. However if I would have started with cc, no matter what I append it will never match. I have explored the Pattern and Matcher class but didn't find any way of achieving this. The input will come from user and system have to wait till pattern matches or it will never match irrespective of any input further. Any clue? Thanks.

    Read the article

  • Regex: Matching a space-joined list of words, excluding last whitespace

    - by Jesper
    How would I match a space separated list of words followed by whitespace and some optional numbers? I have this: >>> import re >>> m = re.match('(?P<words>(\w+\s+)+)(?P<num>\d+)?\r\n', 'Foo Bar 12345\r\n') >>> m.groupdict() {'num': '12345', 'words': 'Foo Bar '} I'd like the words group to not include the last whitespace(s) but I can't figure this one out. I could do a .strip() on the result but that's not as much fun :) Some strings to test and wanted result: 'Foo & Bar 555\r\n' => {'num': '555', 'words': 'Foo & Bar'} 'Hello World\r\n' => {'num': None, 'words': 'Hello World'} 'Spam 99\r\n' => {'num': 99, 'words': 'Spam'} 'Number 1 666\r\n' => {'num': 666, 'words': 'Number 1'}

    Read the article

  • Matching a Repeating Sub Series using a Regular Expression with PowerShell

    - by Hinch
    I have a text file that lists the names of a large number of Excel spreadsheets, and the names of the files that are linked to from the spreadsheets. In simplified form it looks like this: "Parent File1.xls" Link: ChildFileA.xls Link: ChildFileB.xls "ParentFile2.xls" "ParentFile3.xls" Blah Link: ChildFileC.xls Link: ChildFileD.xls More Junk Link: ChildFileE.xls "Parent File4.xls" Link: ChildFileF.xls In this example, ParentFile1.xls has embedded links to ChildFileA.xls and ChildFileB.xls, ParentFile2.xls has no embedded links, and ParentFile3.xls has 3 embedded links. I am trying to write a regular expression in PowerShell that will parse the text file producing output in the following form: ParentFile1.xls:ChildFileA.xls,ChildFileB.xls ParentFile3.xls:ChildFileC.xls,ChildFileD.xls,ChildFileE.xls etc The task is complicated by the fact that the text file contains a lot of junk between each of the lines, and a parent may not always have a child. Furthermore, a single file name may pass over multiple lines. However, it's not as bad as it sounds, as the parent and child file names are always clearly demarcated (the parent with quotes and the child with a prefix of Link: ). The PowerShell code I've been using is as follows: $content = [string]::Join([environment]::NewLine, (Get-Content C:\Temp\text.txt)) $regex = [regex]'(?im)\s*\"(.*)\r?\n?\s*(.*)\"[\s\S]*?Link: (.*)\r?\n?' $regex.Matches($content) | %{$_.Groups[1].Value + $_.Groups[2].Value + ":" + $_.Groups[3].Value} Using the example above, it outputs: ParentFile1.xls:ChildFileA.xls ParentFile2.xls""ParentFile3.xls:ChildFileC.xls ParentFile4.xls:ChildFileF.xls There are two issues. Firstly, the inclusion of the "" instead of a newline whenever a Parent without a Child is processed. And the second issue, which is the most important, is that only a single child is ever shown for each parent. I'm guessing I need to somehow recursively capture and display the multiple child links that exist for each parent, but I'm totally stumped as to how to do this with a regular expression. Amy help would be greatly appreciated. The file contains 100's of thousands of lines, and manual processing is not an option :)

    Read the article

  • Pattern Matching in Scheme

    - by kunjaan
    How do I accept the following input? (list of 0 or more charcters and ends with 3) or (list of 1 or more characters 4 and 0 or more characters after 4) something like (match ( list 3)) -> #t (match ( list 1 2 3)) -> #t (match (list 1 2 3 4)) -> #t (match (list 1 2 3 4 5)) -> #t (match (list 4)) -> #f EDIT: THIS IS NOT MY HOMEWORK. I trying to write something like ELIZA from PAIP but I know only how to write a pattern that begins with a word.

    Read the article

  • Linux RFID reader HID Device not matching driver

    - by blietaer
    Hello, I got a RFID reader (GigaTek PCR330A-00) that is meant to be recognized under linux/windows as a (Human Interface Device) keyboard/USB. I hate to say this but it is working as a charm under Win7 but not "really" under Linux. Under Debian-like distros (x/k/Ubuntu, Debian,..), or Gentoo, or... I just can't have the device working at all: the device scan well (it has its USB 5V, so it is happy/beeping/blinking) something happened in the dmesg, but no immediate screen display of the RFID Tag code as expected (and seen under win7) Support is claiming it is ok under RHEL or SLED "enterprises" distros... and I must admit I saw it working under a RHEL4... I tried stealing the driver but did not succeed having my reader working... My question is thus double: 1./ How can I hack the kernel to add support to my device (simply register PID/VID?) ? 2./ What is different at all in a "enterprise" proprietary distro? how can I re-use it? Thank you for any hint/help. Cheers,

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >