init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Kreta.Core;
|
||||
|
||||
namespace Kreta.BusinessLogic.Extensions
|
||||
{
|
||||
public static class NameExtensions
|
||||
{
|
||||
public static string CleanElotag(this string elotag)
|
||||
{
|
||||
var trimmed = elotag.ReplaceMultipleSpacesAndTrim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(trimmed))
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
return GetStringWithoutDuplicatedDots(trimmed);
|
||||
}
|
||||
|
||||
public static string GetNevSorrendben(string nevSorrend, string nevElotag, string vezetekNev, string keresztNev)
|
||||
=> $"{nevElotag} {(string.Equals(nevSorrend, "F", StringComparison.OrdinalIgnoreCase) ? $"{vezetekNev} {keresztNev}" : $"{keresztNev} {vezetekNev}")}".ReplaceMultipleSpacesAndTrim();
|
||||
|
||||
private static string GetStringWithoutDuplicatedDots(string text)
|
||||
=> NullableRegexReplace(text, @"\.+", ".");
|
||||
|
||||
private static string NullableRegexReplace(this string text, string pattern, string replacement)
|
||||
=> string.IsNullOrWhiteSpace(text) ? text : Regex.Replace(text, pattern, replacement);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user