pattern-matching

Add fields to logstash based off of filebeat data

吃可爱长大的小学妹 提交于 2019-12-12 01:58:15
问题 So, I have a hostname that is being set by filebeat (and I've written a regex that should grab it), but the following isn't adding fields the way that I think it should.. grok{ patterns_dir => "/config/patterns" match =>{ "beat.hostname" => ["%{INSTALLATION}-%{DOMAIN}-%{SERVICE}"] } add_field => { "[installation]" => "%{INSTALLATION}"} add_field => { "[domain]" => "%{DOMAIN}"} add_field => { "[service]" => "%{SERVICE}"} } I can't seem to access beat.hostname, hostname, host or anything like

Return results from regular expression pattern matching

落爺英雄遲暮 提交于 2019-12-12 01:44:15
问题 I have a string (HTML in this example case) which contains the same pattern for displaying the results of sports games. So, the HTML tags are known, but the values for each game are not. In Perl, we can do this: if ( $content =~ /\<\/a\>\<br\>(\d+)\<\/span\>\<br\>(\d+)\-(\d+).+\<\/a\>\<br\>(\d+)\<\/span\>\<br\>(\d+)\-(\d+)/) { $visitingTeamScore = $1; // $1 is the 1st matched digit $visitingTeamWins = $2; // $2 is the 2nd matched digit $visitingTeamLosses = $3; // Etc $homeTeamScore = $4;

How to apply market basket analysis / association rule in QlikView?

余生颓废 提交于 2019-12-12 01:43:42
问题 I want to use Association rule in Qlikview to find out the best product combination. But Im not technically strong in QlikView. Can anyone provide tutorials or can kindly teach me how to use the features in qlikview to performed the association rule.(Time slice is flexible if possible. ) And now currently , I'm trying with this tutorial for Market Basket analysis [ http://www.quickqlearqool.nl/?p=965 ] But it did not count the number of customer for the same purchase behaviour . (within 1

Pattern matching Tkinter child widgets (winfo_children) to determine type

淺唱寂寞╮ 提交于 2019-12-12 01:38:29
问题 I'm trying to automatically clear all Entry widgets in a parent widget. import Tkinter import re root=Tkinter.Tk() E1=Tkinter.Entry(root) E1.pack() E2=Tkinter.Entry(root) E2.pack() L1=Tkinter.Label(root,text='Label1') L1.pack() I'm running into 3 problems While I can find out the children widget type, I can't seem to be able to use it in a pattern match. Printing out the wlist[0] below is different from the shell output? Eg: >> wlist=root.winfo_children() >> wlist [<Tkinter.Entry instance at

Generate regular expressions from strings

删除回忆录丶 提交于 2019-12-12 01:36:13
问题 I have a table (>1Mio rows) with string data, from which I need to extract the patterns. That is, if the first row containts the value 'US003TX' it should generate the pattern [A-Z]{2}\d{3}[A-Z{2} If he search finds a new value it should genderate the next pattern. The pattern can be a regex or some pther pattern description. Is there an (existing) algorithm or library for this? preferrably in c# or .NET. 来源: https://stackoverflow.com/questions/35989564/generate-regular-expressions-from

Regex fails to match string

纵饮孤独 提交于 2019-12-12 01:29:13
问题 I have a piece of code below which I am trying to use to match the start and the end of a string where the middle can change. I am first trying to get this example working could someone please tell me the error with this code and why it is not matching at all. string pattern = @"/\/>[^<]*abc/"; string text = @"<foo/> hello first abc hello second abc <bar/> hello third abc"; Regex r = new Regex(pattern, RegexOptions.IgnoreCase); Match m = r.Match(text); 回答1: You don't need the delimiters, in c

How to match multiline data in perl

狂风中的少年 提交于 2019-12-12 01:29:09
问题 This question refers to How to replace text using greedy approach in sed? I have to match multiline data in file and need to replace them with some other text using perl. cat file <strong>ABC </strong> perl script: code.pl #!/bin/perl open(fh, $ARGV[0]) or die "could not open file\n"; while($input = <fh>) { if($input =~/<strong>(.*?)\n(\s)*<\/strong>/) { print($1,"\n"); } } close(fh); perl code.pl file Output: No output How to solve above pblm. Regards 回答1: use File::Slurp qw( read_file ); my

SQL select rows containing substring in text field

淺唱寂寞╮ 提交于 2019-12-12 01:03:02
问题 I have CLIENTS_WORDS table with columns: ID, CLIENT_ID, WORD in Postgresql database ID|CLIENT_ID|WORD 1 |1242 |word1 2 |1242 |WordX.foo 3 |1372 |nextword 4 |1999 |word1 In this table possible about 100k-500k rows. I have query string like this: 'Some people tell word1 to someone' 'Another stringWordX.foo too possible' I wish select * from table where WORD column text contains in query string. Now I use select select * from CLIENTS_WORDS where strpos('Some people tell word1 to someone', WORD)

Regex that splits long text in separate sentences with match()

天涯浪子 提交于 2019-12-12 00:08:33
问题 This is a textarea where the user writes some text. I've written an example in it. <textarea id="text">First sentence. Second sentence? Third sentence! Fourth sentence. Fifth sentence </textarea> Requirements already considered in the regex separator is included in array item last sentence doesn't necessarily require a separator character (it can end with any character) if a sentence has more than one separator char, it is included in the array item. Example: second sentence?!? should be [...

Detecting groups without recursion or stacks/queues

我与影子孤独终老i 提交于 2019-12-11 23:24:37
问题 I was trying out this algorithm for detecting groups of like pieces on a grid. It is a simple game demo that drops pieces randomly on a 12x10 grid and after each piece drop checks the grid for any groups that are three or more adjacent pieces. I am using the following code in an attempt to do this without flood fill, recursion, or stacks/queues. It seems to almost work, but will destroy squares that are not of the same type sometimes, or leave squares that should be destroyed. So, is the