diff --git a/src/Umbraco.Examine/ExamineExtensions.cs b/src/Umbraco.Examine/ExamineExtensions.cs
index d231a86f69..fb4ad59898 100644
--- a/src/Umbraco.Examine/ExamineExtensions.cs
+++ b/src/Umbraco.Examine/ExamineExtensions.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Examine
///
/// myFieldName_en-us will match the "en-us"
///
- internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^([_\\w]+)_([a-z]{2}-[a-z0-9]{2,4})$", RegexOptions.Compiled);
+ internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^(?[_\\w]+)_(?[a-z]{2,3}(-[a-z0-9]{2,4})?)$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
private static bool _isConfigured = false;
private static object _configuredInit = null;
@@ -67,7 +67,7 @@ namespace Umbraco.Examine
foreach (var field in allFields)
{
var match = CultureIsoCodeFieldNameMatchExpression.Match(field);
- if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value))
+ if (match.Success && culture.InvariantEquals(match.Groups["CultureName"].Value))
yield return field;
}
}
@@ -85,7 +85,7 @@ namespace Umbraco.Examine
foreach (var field in allFields)
{
var match = CultureIsoCodeFieldNameMatchExpression.Match(field);
- if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value))
+ if (match.Success && culture.InvariantEquals(match.Groups["CultureName"].Value))
{
yield return field; //matches this culture field
}
diff --git a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs
index 1e7b51aa14..4d8409754a 100644
--- a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs
+++ b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs
@@ -73,13 +73,13 @@ namespace Umbraco.Examine
return true;
//before we use regex to match do some faster simple matching since this is going to execute quite a lot
- if (!fieldName.Contains("_") || !fieldName.Contains("-"))
+ if (!fieldName.Contains("_"))
return false;
var match = ExamineExtensions.CultureIsoCodeFieldNameMatchExpression.Match(fieldName);
- if (match.Success && match.Groups.Count == 3)
+ if (match.Success)
{
- var nonCultureFieldName = match.Groups[1].Value;
+ var nonCultureFieldName = match.Groups["FieldName"].Value;
//check if there's a definition for this and if so return the field definition for the culture field based on the non-culture field
if (base.TryGetValue(nonCultureFieldName, out var existingFieldDefinition))
{