YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

New Topic Post Reply
Custom Field Priority
Guest
#1 Posted : Wednesday, December 23, 2009 7:11:34 PM


Groups:

Joined: 11/5/2009
Posts: 340

Hi,

I'm new to Grindstone and am greatly enjoying the experience so far. I just had a question regarding the "Advanced Entry" tab under Configure Profile > Modify Custom Field. I have defined a custom field named "Priority" that I group tasks by, and I would like the value to be detected in the name of each task as it is entered. Currently the match pattern is set to: (?<=\()High|Medium|Low(?=\)) so that I can add "(Low)" to the end of a task name to group it into the category "Low." This currently works fine. However, it leaves the set of parentheses () at the end of the task name if "Remove match from name" is checked. So my second attempt was to set the match pattern to \(High|Medium|Low\) in order to grab the whole pattern, and use the format pattern (?<=\()High|Medium|Low(?=\)) in order to control what value the Priority field is set to. Unfortunately, this doesn't seem to work either. Perhaps I am misunderstanding the purpose of the format pattern? I would appreciate any tips in this regard. 

Thanks for a great product!

Daniel Henry
#2 Posted : Wednesday, December 23, 2009 8:05:03 PM


Groups: Epiforge, Windows Dev

Joined: 11/5/2009
Posts: 280
Location: Atlanta, GA

Okay, this question was fun because it sent me on a Grindstone source code safari. Here we have the line that actually determines whether we have a match.

var match = Regex.Match(t.Name, "\\s*(" + customField.MatchPattern + ")\\s*", RegexOptions.IgnoreCase | RegexOptions.Singleline);

As you can see, your expression is both prefixed and suffixed so that it ignores surrounding white space and captures the match. In addition, we're always ignoring case and using single-line mode (just in case you were curious). Also, the format pattern (if present) is applied like this:

string value = match.Groups[1].Value;
if (customField.FormatPattern != null && customField.FormatPattern.Trim().Length > 0)
    value = Regex.Replace(value, customField.MatchPattern, customField.FormatPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);

So, I'm assuming you're wanting to type a task like this: "Some Task (High)". And you want Grindstone to produce a task named "Some Task" and set the custom field's value to "High". In order to do that, you'd need to set the match pattern as something like \((?<p>High|Medium|Low)\) and the format pattern to something like ${p}. And obviously, if you don't want to type the parenthesis it becomes even simpler. For that all you need is a match pattern that's set to High|Medium|Low and no format pattern whatsoever.

One thing to note is that these are being done by .NET's regular expression engine, which may have a slightly different syntax for these format patterns than conventional regular expressions. I'll do some more research into that and if it turns out to be the case, I'll just zap a note over to UX so they can change the embedded user assistance in the Custom Field editor accordingly.

Thanks for one of the best questions I've had so far.

c_07
#3 Posted : Thursday, December 24, 2009 9:20:02 AM


Groups: Registered

Joined: 12/24/2009
Posts: 7
Location: United States

Hi Daniel,

Thanks for the prompt response! Your solution works as expected and seeing it in the context of source code helps my understanding of it. Speaking of which reminds me that I meant to ask if Grindstone's source code is or will in the future be available?

I wonder if you might consider replacing the regex help link on the Modify Custom Field dialog to the .NET regex reference guide: http://msdn.microsoft.com/en-us/library/az24scfc.aspx, since that page explains grouping constructs well. I think, however, that the best thing would be a full explanation of the syntax of both fields in the help content.

EDIT: It seems that I overlooked the named groups page, which even has a helpful note on .NET particulars (2nd paragraph): http://www.regular-expressions.info/named.html

Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.403 beta | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.574 seconds.