pattern-matching

Detect in list2 if there are any strings (whole or part of bigger string) that is contained in list1

时光怂恿深爱的人放手 提交于 2019-12-11 21:15:27
问题 I have two lists: list1<-list("q","w","e","r","t") list2<-list("a","a","aq","c","f","g") I need a code that will give TRUE because q is in the third cell of list2 . I need to search for every cell of list1 in list2 . I mean that I need to search every cell of list2 for any strings that are contained in every cell of list1 . Matching should be as for the whole match but also for partial (if string from list1 is a part of the bigger string in list2 ) and in both cases I need to receive TRUE .

Matching pattern span multiple line and remove those matching lines

心已入冬 提交于 2019-12-11 20:12:58
问题 I was trying to use sed to do the following: In file looks something like: FirstLine SecondLine EEE AAA blablabla ForthLineEEE FifthLine LastLine I want to remove EEE (but keep the rest of second line) and the whole line starting with AAA and keep other part of the file intact. The expected result is (as seen, if the following line doesn't start with AAA, it will be kept, that's why I need to match multiple lines.) FirstLine SecondLine ForthLineEEE FifthLine LastLine How should I do it?

Writing a macro that contains a match body

元气小坏坏 提交于 2019-12-11 20:10:02
问题 I'm attempting to condense some repetitive code that has structure similar to: match self.foo() { None => self.bar(), Some(MyStruct { foo: x, .. }) => match x { Pattern1 => result, Pattern2 => { block_result } } } which I would like to write as something like: my_macro!( Pattern1 => result, Pattern2 => { block_result } ) avoiding the repetitive None handling and MyStruct destructuring. This seems like it should be pretty simple, as it's essentially just substituting the macro body into a

Count the number of variable combinations in a logfile using perl

一世执手 提交于 2019-12-11 20:01:48
问题 I have this logfile New connection: 141.8.83.213:64400 (172.17.0.6:2222) [session: e696835c] 2016-04-29 21:13:59+0000 [SSHService ssh-userauth on HoneyPotTransport,3,141.8.83.213] login attempt [user1/test123] failed 2016-04-29 21:14:10+0000 [SSHService ssh-userauth on HoneyPotTransport,3,141.8.83.213] login attempt [user1/test1234] failed 2016-04-29 21:14:13+0000 [SSHService ssh-userauth on HoneyPotTransport,3,141.8.83.213] login attempt [user1/test123] failed I want to output to file a

Whitespace in Java's regular expression

送分小仙女□ 提交于 2019-12-11 19:46:56
问题 I'm trying to write a regular expression to mach an IRC PRIVMSG string. It is something like: :nick!name@some.host.com PRIVMSG #channel :message body So i wrote the following code: Pattern pattern = Pattern.compile("^:.*\\sPRIVMSG\\s#.*\\s:"); Matcher matcher = pattern.matcher(msg); if(matcher.matches()) { System.out.println(msg); } It does not work. I got no matches. When I test the regular expression using online javascript testers, I got matches. I tried to find the reason, why it doesn't

Parsing file and detection of pattern in Java

孤街浪徒 提交于 2019-12-11 16:43:19
问题 My problem is quite simple, i am parsing a CSV file, line after line and i want to get the values of the columns. The separators used are simply " ; ", but my file can have quite a lot of columns, and they won't be always in the same order. So as example for my .CSV file : time;columnA;columnB,ColumnC 27-08-2013 14:43:00; this is a text; this too; same here And i would like to be able to get all the values of time, columnA, columnB and columnC. What would be the easiest way? I used

Postgres match operator @@

▼魔方 西西 提交于 2019-12-11 16:34:50
问题 I'm trying to figure out how exactly does @@ operator work in postgres. I have the two queries: SELECT description FROM product WHERE description @@ '%apple%' SELECT description FROM product WHERE description @@ 'apple' The two queries return the same number of rows. Apparently postgres removes all non alfanumeric characters from the query. Is this actually the case? I can also do @@ '@apple..,,.' and I still get the same number of results. 回答1: @@ operator is part of TSearch2 Full Text

Creating dataset based on different case classes [duplicate]

*爱你&永不变心* 提交于 2019-12-11 16:33:25
问题 This question already has an answer here : Encode an ADT / sealed trait hierarchy into Spark DataSet column (1 answer) Closed last year . Hi I have an RDD which is basically made after reading a CSV file. I have defined a method which basically maps the lines of rdd to different case classes based on input parameter. The RDD returned need to be converted to dataframe When I try to run the same I get below error. Method defined is case class Australiafile1(sectionName: String, profitCentre:

How To Match Content Between Tags Without Regex

左心房为你撑大大i 提交于 2019-12-11 15:33:19
问题 I have read the following post about How to match content between HTML specific tags with attribute using grep?. However, when I use the code derived from that page, I'm unable to match the content. I keep getting a blank output. Here's the code I'm using: grep -oP '(?<=<div class="tag"> ).*?(?= </tag>)' file1.txt I've ensured that all the line endings are in linux (LF). Here's file1.txt: <div class="tag"> <p>hello world!</p> </tag><!-- .end-section --> I would want the output: <div class=

rabbitmq ldap authorization for groups with inconsistent user DNs

只愿长相守 提交于 2019-12-11 15:22:00
问题 I'm trying to set up rabbitmq authorization against LDAP (Microsoft Active Directory) using the in_group or in_group_nested queries. However, since our OU structure is inconsistent across our users, which results in a variety of DN patterns, I had to rely on a user_dn_pattern that simply passes the "domain\account" when binding, which works great from an authentication perspective with Microsoft Active Directory. However, when it comes to the in_group / in_group_nested queries, it doesn't