Category "pattern-matching"

Grok pattern to remove "ms" from log string and convert to INT

first time long time. I have this log message: 2022/05/04 09:24:08 INTERESTING UpdateStatus: active: 45 waiting: 0 connections: 91 max dbcmd queue length: 3 max

Why isn't (20 >) . length . take 10 === const True

tl;dr Isn't the fact that 20 < length $ take 10 $ whatever requires whatever to successfully pattern patch a list (at least either [] or (_:_)) a "lack" of l

Alternative function for case match in haskell

I am writing an API in Haskell which involves a DB query. Function will be something like do a db query and then return the response back. doAPICall :: Request

How to filter all rows between two values containing a certain pattern for a list of data frames in R?

I have a large list of about thousand data frames and want to filter all the rows from between two values which contain a string pattern VALUE1 and VALUE2 in th

How to do structural pattern matching in Python 3.10 with a type to match?

I am trying to match a type in Python 3.10 using the console: t = 12.0 match type(t): case int: print("int") case float: print("float") And I get t

How to get part of string from regex in Java

For example, I have string with range of earnings: 5 000-10 000 USD and i want to extract from that string minimum and maximum value. I prepared regexes, for e

Safe regex patterns from ReDos attack

I've recently faced with some redos attack issues. Explain in simple steps: Regex denial of services: it means the attacker can put some malicious/crafted input

Java string matching with wildcards

I have a pattern string with a wild card say X (E.g.: abc*). Also I have a set of strings which I have to match against the given pattern. E.g.: abf - false

Match list of words without the list of chars around

I have this regex (?:$|^| )(one|common|word|or|another)(?:$|^| ) which matches fine unless the two words are next to each other. One one's more word'word commo

Generic Ruby solution for SQLite3 "LIKE" or PostgreSQL "ILIKE"?

I am using SQLite3 for development and PostgreSQL for deployment. However, I am facing the following problem: My simple search using SQLite3: def self.search(