天道酬勤,学无止境

multiple-matches

VBA使用正则表达式execute方法在一个字符串中进行多个匹配(VBA multiple matches within one string using regular expressions execute method)

问题 我正在尝试根据1.学位2.多年的经验来匹配各个职位的经验水平。 模式非常简单(例如:“ BS / 5”将是拥有5年经验的理科学士。我也有遵循此方案的条目,但在同一字符串中具有多个学位和经验水平(例如:“ BS / 5-MS / 2“)被认为是等效的。我有一个基本函数,它将匹配并找到子字符串模式,但是即使将regexp的.Global属性设置为true,它也不会返回多个匹配项对象。有什么想法吗?下面的代码: On Error Resume Next ActiveWorkbook.VBProject.References.AddFromGuid "{3F4DACA7-160D-11D2-A8E9-00104B365C9F}", 5, 5 Dim theRegex As Object Dim theString As String Set theRegex = CreateObject("VBScript.RegExp") With regex .MultiLine = False .Global = True .IgnoreCase = False End With theRegex.Pattern = "([A-z][A-z][A-z]?/[0-9][0-9]?)" theString = "MS/9-PhD/4" Set MyMatches = theRegex

2021-05-18 10:06:18    分类:技术分享    regex   vba   substring   multiple-matches

如何在Java中获得多个正则表达式匹配项?(How to get multiple regex matches in Java?)

问题 如何找到与Java中的正则表达式匹配的所有子字符串? (类似于.Net中的Regex.Matches) 回答1 创建一个Matcher并使用find()将其放置在下一个匹配项上。 回答2 这是一个代码示例: int countMatches(Pattern pattern, String str) { int matches = 0; Matcher matcher = pattern.matcher(str); while (matcher.find()) matches++; return matches; }

2021-04-22 13:30:30    分类:技术分享    java   regex   multiple-matches

VBA multiple matches within one string using regular expressions execute method

I'm trying to match experience levels for various positions based on 1. Degree 2. Years of Experience. The pattern is fairly simple (example: "BS/5" would be a bachelors of science with 5 years of experience. I also have entries that follow this scheme but have multiple degrees and experience levels in the same string (example: "BS/5-MS/2") that are considered equivalent. I've got a basic function that will match and find the substring pattern but it never returns more than one match even though I've set the .Global property to true for the regexp object. Any ideas? Code below: On Error Resume

2021-04-19 10:47:14    分类:问答    regex   vba   substring   multiple-matches

How to get multiple regex matches in Java?

How can I find all substrings that match a regex in Java? (Similar to Regex.Matches in .Net)

2021-04-10 20:39:13    分类:问答    java   regex   multiple-matches

使用dplyr contains()根据多个字符串选择列(select columns based on multiple strings with dplyr contains())

问题 我想使用正则表达式根据其名称选择多个列。 我正在尝试使用dplyr软件包的管道语法。 我检查了其他主题,但仅找到有关单个字符串的答案。 使用基数R: library(dplyr) mtcars[grepl('m|ar', names(mtcars))] ### mpg am gear carb ### Mazda RX4 21.0 1 4 4 ### Mazda RX4 Wag 21.0 1 4 4 但是,它不适用于选择/包含方式: mtcars %>% select(contains('m|ar')) ### data frame with 0 columns and 32 rows 怎么了? 回答1 您可以使用matches mtcars %>% select(matches('m|ar')) %>% head(2) # mpg am gear carb #Mazda RX4 21 1 4 4 #Mazda RX4 Wag 21 1 4 4 根据?select文档 'matches(x,ignore.case = TRUE)':选择名称与正则表达式'x'匹配的所有变量 虽然contains单个字符串的工作 mtcars %>% select(contains('m'))

2021-04-10 17:12:17    分类:技术分享    r   regex   dplyr   matching   multiple-matches

select columns based on multiple strings with dplyr contains()

I want to select multiple columns based on their names with a regex expression. I am trying to do it with the piping syntax of the dplyr package. I checked the other topics, but only found answers about a single string. With base R: library(dplyr) mtcars[grepl('m|ar', names(mtcars))] ### mpg am gear carb ### Mazda RX4 21.0 1 4 4 ### Mazda RX4 Wag 21.0 1 4 4 However it doesn't work with the select/contains way: mtcars %>% select(contains('m|ar')) ### data frame with 0 columns and 32 rows What's wrong?

2021-03-31 00:17:36    分类:问答    r   regex   dplyr   matching   multiple-matches