regex that matches simple arithmetic expressions

Advertisements i have a solution, but the only problem is that for example "7=7=7" is matched and that should not be the case. ^[+-]?\d+([/*+-]\d+)*([/*+-]*=(?:[+-]?\d+([/*+-]\d+)*)+)*$ see below of what is matched and not these are matched and that is correct 456+5 0 0+0 5=0 1589+232 55+2 5+55 545454545 -12*53+1-2/5 +1+2+3=-5*2/3 000=0 18=+17/25 0-0 0*0 0/0 1/1… Read More regex that matches simple arithmetic expressions

How do I find Regex Matches in an array including repeats in C#

Advertisements I have a method in C# that uses Regex to find any strings that match any {{word:word}} pattern: private string ModifyVariables(string text) { String pattern = @"{{([\w|]+:\w+)}}"; MatchCollection matches = Regex.Matches(text, pattern); for (int i = 0; i < matches.Count; i++) { Match match = Regex.Match(text, pattern); string value = GetVariableValue(match.Value); text = text.Replace(match.Value,… Read More How do I find Regex Matches in an array including repeats in C#

How to use `separate_wider_regex()` function?

Advertisements I’m trying to use the new separate_wider_regex() function to separate a string. In the first example (moldavia_1), we have a pattern. So, it is simple to obtain all the columns: moldavia_1 <- tibble(adresa = c("1;MD-3101,Balti str-la Botu Pavel 3", "3;MD-3102,Balti str-la Muresanu A. 11", "17;MD-3102,Balti str-la Sorocii 46", "398;MD-3111,Balti str-la Stefan cel Mare 20",… Read More How to use `separate_wider_regex()` function?

Split text into list of words contains only letters

Advertisements I’m trying to split a text into a list of words that a word should contain only letters. I tried this pattern [^a-zA-Z]+ like below: var regex = new Regex(@"[^a-zA-Z]+", RegexOptions.Singleline | RegexOptions.Compiled); var words = regex.Split(text).Where(w => !string.IsNullOrEmpty(w)) When the input is This is a t3st, it returns ["This", "is", "a", "t", "st"]… Read More Split text into list of words contains only letters

Regex to match backslash unless followed by _, %, ' or an odd number of backslashes

Advertisements I’m trying to write a regex expression to select a backslash. The problem is that I only want to select it if it’s not followed by an odd number of backslashes, or one of the characters in this set: [_%’]. I don’t mind which backslash in the sequence is selected, first or last, I… Read More Regex to match backslash unless followed by _, %, ' or an odd number of backslashes

Regex to match backslash unless followed by _, %, ' or an odd number of backslashes

Advertisements I’m trying to write a regex expression to select a backslash. The problem is that I only want to select it if it’s not followed by an odd number of backslashes, or one of the characters in this set: [_%’]. I don’t mind which backslash in the sequence is selected, first or last, I… Read More Regex to match backslash unless followed by _, %, ' or an odd number of backslashes

Getting unexpected results from regex.test() and my debugged code (filled with logs) works but I don't know why

Advertisements I’m trying to find all instances of a query within a set of data pulled from my workbook. The query could be found in one of two columns and may exist in one or multiple rows. The solution I came up with works, I’ve tested it with multiple cases using Quokka.js before moving my… Read More Getting unexpected results from regex.test() and my debugged code (filled with logs) works but I don't know why

How do I extract a substring that follows a specific keyword in R?

Advertisements I would like to extract people’s names that come after the words "Administering Provider". The name could be composed of first, middle, and last name (sometimes just first and last). Also if there’s a person title after their name e.g.: Dr. I’m not interested in it df <- data.frame("id"= c(12, 19, 20), ‘comments’ =… Read More How do I extract a substring that follows a specific keyword in R?