match

Match several occurrences or zero (in this order) using regular expressions

Hello all, I want to match roman numbers using Groovy regular expressions (I have not tried this in Java but should be the same). I found an answer in this website in which someone suggested the following regex: /M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})/ The problem is that a expression like /V?I{0,3}/ is not greedy in ...

How can I test if a filename matching a pattern exists in Perl?

Can I do something like this in Perl? Meaning pattern match on a file name and check whether it exists. if(-e "*.file") { <Do something> } I know the longer solution of asking system to list the files present; read it as a file and then infer whether file exists or not. ...

Problem searching MySQL table using MATCH AGAINST

Hi there, I have a MySQL table containing event data. On this table, I have a FULLTEXT index, incorporating event_title,event_summary,event_details of types varchar,text,text respectively. Examples of titles include: "Connections Count", "First Aid", "Health & Safety". I can search the table as follows: SELECT * FROM events WHERE MA...

Python - Non-matching regex

Hey, I have the following regex: regex = compile("((?P<lastyear>[\dBFUPR]+)/)*((?P<lastseason>[\dBFUPR]+))*(^|-(?P<thisseason>[\dBFUPR]*))") Which I am using to process horce racing form strings. Sometimes a horses' form will look like this "1234-" meaning that it has not raced yet this season (there are no numbers to the right of th...

Can anyone point me toward a content relevance algorithm?

A new project with some interesting requirements has arrived on my desk. I need to develop a searchable directory of businesses, with a focus on delivering relevant results based on arbitrary search queries. The businesses can be of any niche; there's no one area that is more represented than another. When googling for things like "se...

.NET regex multiline help - regular expression

I've got a multiline string like this. Ity has line feeds. [Site Url="http://medportal.domain.edu" Owner="DOMAIN\user1" SecondaryOwner="DOMAIN\user2" ContentDatabase="WSS_Content_$1" StorageUsedMB="0.8" StorageWarningMB="0" StorageMaxMB="0" /] [Site Url="http://medportal.domain.edu/sites/ahSC" Owner="DOMAIN\user1" ContentDatabase="WSS...

C# Replacing matching substrings in a string

Hi. How do I remove all matching substrings in a string? For example if I have 20 40 30 30 30 30, then I just 20 40 30 (and not the other 30s). Do I use a regex? If so, how? ...

Scala pattern matching keep saying "match is not exhaustive!"

I want to leverage the warning that Scala issues when a matching is missing ("not exhaustive") - so that I don't forget one (I have dozens). The following simplified example shows my attempt: sealed case class MESSAGE() class SUCCESS_MESSAGE extends MESSAGE class FAILURE_MESSAGE extends MESSAGE def log(str: String, msgType: MESSAGE) { ...

Mysql REGEXP 'o' OR 'aw'

I'm trying to do a friend search app. So to do that I'm using regular expressions like: SELECT ... WHERE firstname REGEXP $firstname And the $firstname variable is a string - for example: (ch|k)ris But for some reason it does not work. maybe the ( | ) doesn't work in MySQL? What can I use instead of that operator to do the same ...