Skip to content

Commit 7d98263

Browse files
committed
Extend character set of function names (including ".") (again)
1 parent 26a1e34 commit 7d98263

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Source/ExcelDna.IntelliSense/UIMonitor/FormulaParser.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ static class FormulaParser
88
{
99
// Set from IntelliSenseDisplay.Initialize
1010
public static char ListSeparator = ',';
11+
// TODO: What's the Unicode situation?
12+
public static string forbiddenNameCharacters = @"\ /\-:;!@\#\$%\^&\*\(\)\+=,<>\[\]{}|'\""";
13+
public static string functionNameRegex = "[" + forbiddenNameCharacters + "](?<functionName>[^" + forbiddenNameCharacters + "]*)$";
14+
public static string functionNameGroupName = "functionName";
1115

1216
internal static bool TryGetFormulaInfo(string formulaPrefix, out string functionName, out int currentArgIndex)
1317
{
@@ -22,10 +26,10 @@ internal static bool TryGetFormulaInfo(string formulaPrefix, out string function
2226

2327
if (lastOpeningParenthesis > -1)
2428
{
25-
var match = Regex.Match(formulaPrefix.Substring(0, lastOpeningParenthesis), @"[^\w.](?<functionName>[\w.]*)$");
29+
var match = Regex.Match(formulaPrefix.Substring(0, lastOpeningParenthesis), functionNameRegex);
2630
if (match.Success)
2731
{
28-
functionName = match.Groups["functionName"].Value;
32+
functionName = match.Groups[functionNameGroupName].Value;
2933
currentArgIndex = formulaPrefix.Substring(lastOpeningParenthesis, formulaPrefix.Length - lastOpeningParenthesis).Count(c => c == ListSeparator);
3034
return true;
3135
}

0 commit comments

Comments
 (0)