capture-group

Code to parse capture groups in regular expressions into a tree

I need to identify (potentially nested) capture groups within regular expressions and create a tree. The particular target is Java-1.6 and I'd ideally like Java code. A simple example is: "(a(b|c)d(e(f*g))h)" which would be parsed to "a(b|c)d(e(f*g))h" ... "b|c" ... "e(f*g)" ... "f*g" The solution should ideally account for cou...

C# Regex: How Can I Replace Tokens With Strings Generated at Run-time?

Given the following input and regex strings: const string inputString = "${Principal}*${Rate}*${Years}"; const string tokenMatchRegexString = @"\${([^}]+)}"; How can I replace each token (i.e. ${Principal}, ${Rate}, and ${Years}) with the return value of my 'ReplaceToken' function? private static string ReplaceToken(string tokenStrin...

extract last match from string in c#

i have strings in the form [abc].[some other string].[can.also.contain.periods].[our match] i now want to match the string "our match" (i.e. without the brackets), so i played around with lookarounds and whatnot. i now get the correct match, but i don't think this is a clean solution. (?<=\.?\[) starts with '[' or '.[' ([^\[]*) ...

Help with a regex expression

I am trying to get the word after Sysdba. out of a string. Here is a example where my result would be PRODUCTION CAST(CASE WHEN SYSDBA.PRODUCTION.SHIPPING_COMPLETE_DATE IS NOT NULL THEN 1 ELSE 0 END AS bit) AS [Shiping Completed]] I created the regex expression Regex CatagoryRegex = new Regex(@"SYSDBA\.(.#)\.", RegexOptions.IgnoreCa...