Here are the examples of the csharp api System.Text.RegularExpressions.Regex.IsMatch(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2100 Examples
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsHaveHiragana(string str)
{
return hiraganaRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsHaveKatakana(string str)
{
return KatakanaRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsSkipCode(string str)
{
return !notSkipCodeRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsKatakanaOnly(string str)
{
//WARNING: Different with the original java code
//we use regex here instead of checking for each char
return !notKatakanaRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsHiraganaOnly(string str)
{
//WARNING: Different with the original java code
//we use regex here instead of checking for each char
return !notHiraganaRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IsKanjiOnly(string str)
{
return !notKanjiRegex.IsMatch(str);
}
19
Source : StringHelper.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
public static bool IBasicLatinOnly(string str)
{
return !notBasicLatin.IsMatch(str);
}
19
Source : JmdictEntity.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
private static bool IsHasKanji(string word)
{
return kanjiRegex.IsMatch(word);
}
19
Source : WikiTextTableParser.cs
with MIT License
from AnnoDesigner
with MIT License
from AnnoDesigner
private static List<WikiTextTableEntry> ParseTableEntry(string curTable)
{
var allEntries = new List<WikiTextTableEntry>();
var regionInfo = GetRegionAndTierInfo(curTable);
WikiTextTableEntry curEntry = null;
var entryCounter = 0;
var lastLineWasCollapsible = false;
//read string line by line
//use StringReader?
foreach (var curLine in curTable.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
//line is a collapsible information
if (lastLineWasCollapsible)
{
lastLineWasCollapsible = !lastLineWasCollapsible;
continue;
}
if (curLine.StartsWith("!", StringComparison.OrdinalIgnoreCase) && curLine.Contains("colspan=\"6\""))
{
lastLineWasCollapsible = true;
continue;
}
//line is empty
if (string.IsNullOrWhiteSpace(curLine))
{
continue;
}
//line has no useful information
if (curLine.Equals(STYLE_INFO, StringComparison.OrdinalIgnoreCase) &&
entryCounter != 4)//there are buildings without maintenance cost
{
continue;
}
//line is end of table
if (curLine.Equals("=", StringComparison.OrdinalIgnoreCase))
{
continue;
}
//line contains description
if (!curLine.StartsWith("|", StringComparison.OrdinalIgnoreCase) &&
!curLine.StartsWith("(", StringComparison.OrdinalIgnoreCase) &&
!regexSize.IsMatch(curLine))
{
curEntry.Description += $"{Environment.NewLine}{curLine}";
continue;
}
//line contains radius info
if (curLine.StartsWith("(", StringComparison.OrdinalIgnoreCase))
{
curEntry.Size += $"{Environment.NewLine}{curLine}";
continue;
}
//start new entry
if (curLine.StartsWith("|-", StringComparison.OrdinalIgnoreCase))
{
if (curEntry != null)
{
allEntries.Add(curEntry);
}
entryCounter = 0;
curEntry = new WikiTextTableEntry
{
Region = regionInfo.Item1,
Tier = regionInfo.Item2
};
continue;
}
switch (entryCounter)
{
case 0:
{
curEntry.Icon = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 1:
{
curEntry.Name = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 2:
{
curEntry.Description = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 3:
{
curEntry.ConstructionCost = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
entryCounter++;
break;
}
case 4:
{
curEntry.MaintenanceCost = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty)
.Replace("−", "-");//can't parse as negative number
entryCounter++;
break;
}
case 5:
{
if (curLine.StartsWith("|", StringComparison.OrdinalIgnoreCase))
{
curEntry.Size = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
}
else
{
curEntry.Size = curLine.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
}
entryCounter++;
break;
}
default:
break;
}
}
//add last entry
if (curEntry != null && !allEntries.Contains(curEntry))
{
allEntries.Add(curEntry);
}
return allEntries;
}
19
Source : TimelineImageNoticeModel.cs
with BSD 3-Clause "New" or "Revised" License
from anoyetta
with BSD 3-Clause "New" or "Revised" License
from anoyetta
private static BitmapSource GetBitmapImageFromUrl(
string image)
{
if (!UriRegex.IsMatch(image))
{
return null;
}
var bitmap = default(BitmapImage);
if (WebImageDictionary.ContainsKey(image))
{
bitmap = WebImageDictionary[image];
}
else
{
using (var web = new WebClient())
{
var bytes = web.DownloadData(image);
using (var stream = new MemoryStream(bytes))
{
bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = stream;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze();
}
}
WebImageDictionary[image] = bitmap;
}
return bitmap;
}
19
Source : ChatOverlaySettingsModel.cs
with MIT License
from anoyetta
with MIT License
from anoyetta
public bool IsMatch(
string logMessage)
{
if (string.IsNullOrEmpty(logMessage) ||
string.IsNullOrEmpty(this.Keyword))
{
return false;
}
var result = false;
switch (this.filterType)
{
case FilterTypes.FullMatch:
result = this.keyword.Equals(logMessage, StringComparison.OrdinalIgnoreCase);
break;
case FilterTypes.Contains:
result = logMessage.IndexOf(this.keyword, StringComparison.OrdinalIgnoreCase) > -1;
break;
case FilterTypes.StartWith:
result = logMessage.StartsWith(this.keyword, StringComparison.OrdinalIgnoreCase);
break;
case FilterTypes.EndWith:
result = logMessage.EndsWith(this.keyword, StringComparison.OrdinalIgnoreCase);
break;
case FilterTypes.Regex:
if (this.filterRegex != null)
{
result = this.filterRegex.IsMatch(logMessage);
}
break;
}
return result;
}
19
Source : NameFilter.cs
with GNU General Public License v3.0
from anydream
with GNU General Public License v3.0
from anydream
public bool IsIncluded(string name)
{
bool result = false;
if (inclusions_.Count == 0) {
result = true;
} else {
foreach (Regex r in inclusions_) {
if (r.IsMatch(name)) {
result = true;
break;
}
}
}
return result;
}
19
Source : NameFilter.cs
with GNU General Public License v3.0
from anydream
with GNU General Public License v3.0
from anydream
public bool IsExcluded(string name)
{
bool result = false;
foreach (Regex r in exclusions_) {
if (r.IsMatch(name)) {
result = true;
break;
}
}
return result;
}
19
Source : FileSelector.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
private bool _Evaluate(string fullpath)
{
CriterionTrace("NameCriterion::Evaluate({0})", fullpath);
// No slash in the pattern implicitly means recurse, which means compare to
// filename only, not full path.
String f = (_MatchingFileSpec.IndexOf('\\') == -1)
? System.IO.Path.GetFileName(fullpath)
: fullpath; // compare to fullpath
bool result = _re.IsMatch(f);
if (Operator != ComparisonOperator.EqualTo)
result = !result;
return result;
}
19
Source : StringExtensions.cs
with MIT License
from aprilyush
with MIT License
from aprilyush
public static bool IsIP(this string _ip)
{
string _express = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
if (_ip.Length == 0)
{
return false;
}
Regex regex = new Regex(_express);
return regex.IsMatch(_ip);
}
19
Source : ExpressionNode.cs
with MIT License
from aprilyush
with MIT License
from aprilyush
public static bool IsNumerics(string op)
{
return Numerics.IsMatch(op);
}
19
Source : StringExtensions.cs
with MIT License
from arbelatech
with MIT License
from arbelatech
public static bool MatchesFileWildcard(this string s, string pattern)
{
Argument.EnsureNotNull(s, nameof(s));
Argument.EnsureNotNull(pattern, nameof(pattern));
var filename = Path.GetFileName(s);
var regex = new Regex(pattern.Replace(".", "\\.").Replace("*", ".*").Replace("?", "."), RegexOptions.IgnoreCase);
return regex.IsMatch(filename);
}
19
Source : PasswordValidator.cs
with MIT License
from ArchitectNow
with MIT License
from ArchitectNow
protected override bool IsValid(PropertyValidatorContext context)
{
return context.PropertyValue == null || _regex.IsMatch((string) context.PropertyValue);
}
19
Source : KeyVaultCachedSecretProvider.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
public virtual async Task<Secret> StoreSecretAsync(string secretName, string secretValue)
{
Guard.NotNullOrWhitespace(secretName, nameof(secretName), "Requires a non-blank secret name to request a secret in Azure Key Vault");
Guard.NotNullOrWhitespace(secretValue, nameof(secretValue), "Requires a non-blank secret value to store a secret in Azure Key Vault");
Guard.For<FormatException>(() => !SecretNameRegex.IsMatch(secretName), "Requires a secret name in the correct format to request a secret in Azure Key Vault, see https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates#objects-identifiers-and-versioning");
Secret secret = await _secretProvider.StoreSecretAsync(secretName, secretValue);
MemoryCache.Set(secretName, secret, CacheEntry);
return secret;
}
19
Source : KeyVaultSecretProvider.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
public virtual async Task<string> GetRawSecretAsync(string secretName)
{
Guard.NotNullOrWhitespace(secretName, nameof(secretName), "Requires a non-blank secret name to request a secret in Azure Key Vault");
Guard.For<FormatException>(() => !SecretNameRegex.IsMatch(secretName), "Requires a secret name in the correct format to request a secret in Azure Key Vault, see https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates#objects-identifiers-and-versioning");
Secret secret = await GetSecretAsync(secretName);
return secret?.Value;
}
19
Source : KeyVaultSecretProvider.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
public virtual async Task<Secret> GetSecretAsync(string secretName)
{
Guard.NotNullOrWhitespace(secretName, nameof(secretName), "Requires a non-blank secret name to request a secret in Azure Key Vault");
Guard.For<FormatException>(() => !SecretNameRegex.IsMatch(secretName), "Requires a secret name in the correct format to request a secret in Azure Key Vault, see https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates#objects-identifiers-and-versioning");
var isSuccessful = false;
using (DependencyMeasurement measurement = DependencyMeasurement.Start())
{
try
{
Secret secret = await GetSecretCoreAsync(secretName);
isSuccessful = true;
return secret;
}
finally
{
if (_options.TrackDependency)
{
Logger.LogDependency(DependencyName, secretName, VaultUri, isSuccessful, measurement);
}
}
}
}
19
Source : KeyVaultSecretProvider.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
public virtual async Task<Secret> StoreSecretAsync(string secretName, string secretValue)
{
Guard.NotNullOrWhitespace(secretName, nameof(secretName), "Requires a non-blank secret name to request a secret in Azure Key Vault");
Guard.NotNullOrWhitespace(secretValue, nameof(secretValue), "Requires a non-blank secret value to store a secret in Azure Key Vault");
Guard.For<FormatException>(() => !SecretNameRegex.IsMatch(secretName), "Requires a secret name in the correct format to request a secret in Azure Key Vault, see https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates#objects-identifiers-and-versioning");
Task<Secret> storeSecretTask;
if (_isUsingAzureSdk)
{
storeSecretTask = StoreSecretUsingSecretClientAsync(secretName, secretValue);
}
else
{
storeSecretTask = StoreSecretUsingKeyVaultClientAsync(secretName, secretValue);
}
Logger.LogTrace("Storing secret {SecretName} from Azure Key Vault {VaultUri}...", secretName, VaultUri);
var secret = await storeSecretTask;
Logger.LogTrace("Got secret from Azure Key Vault {VaultUri}", secret.Version, VaultUri);
return secret;
}
19
Source : HttpCorrelation.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
private bool MatchesRequestIdFormat(string requestId)
{
try
{
return RequestIdRegex.IsMatch(requestId);
}
catch (RegexMatchTimeoutException exception)
{
_logger.LogTrace(exception, "Upstream service's '{HeaderName}' was timed-out during regular expression validation", _options.UpstreamService.OperationParentIdHeaderName);
return false;
}
}
19
Source : ArkClusterData.cs
with MIT License
from ark-mod
with MIT License
from ark-mod
public ArkClusterDataUpdateResult Update(CancellationToken ct, bool deferApplyNewData = false, ArkAnonymizeData anonymize = null)
{
var success = false;
var cancelled = false;
var st = Stopwatch.StartNew();
try
{
var exclusivePropertyNameTree = _loadOnlyPropertiesInDomain ? ArkClusterDataContainerBase._alldependencies : null;
// Extract all cluster data
var arkcloudInventories = Directory.GetFiles(_savePath, "*", SearchOption.TopDirectoryOnly)
.Where(x => /*avoid loading duplicate cluster files*/ r_clusterFiles.IsMatch(Path.GetFileName(x)))
.Select(x =>
{
try
{
var settings = ArkToolkit.DefaultSettings.Invoke();
settings.ExclusivePropertyNameTree = exclusivePropertyNameTree;
return ArkToolkitLoader.Create(settings).LoadClusterSave(x);
}
catch (Exception ex)
{
_logger.Warn($"Failed to load cluster save", ex);
}
return null;
}).Where(x => x != null).ToArray();
var cloudInventories = arkcloudInventories.Select(x =>
{
var inventoryData = x.objects.FirstOrDefault(x => x.clreplacedName.Token.Equals("ArkCloudInventoryData"));
return new { ci = x, id = inventoryData };
}).Where(x => x.id != null).Select(x => x.id.AsCloudInventory(x.ci.steamId, x.ci)).ToArray();
ApplyOrSaveNewData(deferApplyNewData, cloudInventories);
success = true;
}
catch (OperationCanceledException)
{
cancelled = true;
}
return new ArkClusterDataUpdateResult { Success = success, Cancelled = cancelled, Elapsed = st.Elapsed };
}
19
Source : EmailValidator.cs
with MIT License
from ARKlab
with MIT License
from ARKlab
public static bool IsValid(string emailAddress)
{
return Regex.IsMatch(emailAddress);
}
19
Source : Polytomise_node.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public static void Transform(ref TreeNode tree, Dictionary<string, object> parameterValues, Action<double> progressAction)
{
int mode = (int)parameterValues["Mode:"];
bool allChildren = (bool)parameterValues["Apply recursively to all children"];
if (mode == 0)
{
string[] nodeElements = (string[])parameterValues["Node:"];
TreeNode node = tree.GetLastCommonAncestor(nodeElements);
if (node == null)
{
throw new Exception("Could not find the requested node! If you have changed the Name of some nodes, please select the node again!");
}
PolytomiseNode(node, allChildren);
}
else if (mode == 1)
{
List<TreeNode> nodes = tree.GetChildrenRecursive();
string attributeName = (string)parameterValues["Attribute:"];
string attrType = (string)parameterValues["Attribute type:"];
string attrValue = (string)parameterValues["Value:"];
double numberNeedle = attrType == "Number" ? double.Parse(attrValue) : -1;
int comparisonType = attrType == "String" ? (int)parameterValues["Comparison type:"] : (int)parameterValues["Comparison type: "];
bool regex = (bool)parameterValues["Regex"];
StringComparison comparison = StringComparison.InvariantCulture;
RegexOptions options = RegexOptions.CultureInvariant;
switch (comparisonType)
{
case 0:
comparison = StringComparison.InvariantCulture;
options = RegexOptions.CultureInvariant;
break;
case 1:
comparison = StringComparison.InvariantCultureIgnoreCase;
options = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
break;
case 2:
comparison = StringComparison.CurrentCulture;
options = RegexOptions.None;
break;
case 3:
comparison = StringComparison.CurrentCultureIgnoreCase;
options = RegexOptions.IgnoreCase;
break;
}
Regex reg = regex ? new Regex(attrValue, options) : null;
foreach (TreeNode node in nodes)
{
bool matched = false;
if (node.Attributes.TryGetValue(attributeName, out object attributeValue))
{
if (attrType == "String" && attributeValue is string actualValue)
{
if (regex)
{
if (reg.IsMatch(actualValue))
{
matched = true;
}
}
else
{
if (actualValue.Contains(attrValue, comparison))
{
matched = true;
}
}
}
else if (attrType == "Number" && attributeValue is double actualNumber)
{
switch (comparisonType)
{
case 0:
if (actualNumber == numberNeedle)
{
matched = true;
}
break;
case 1:
if (actualNumber < numberNeedle)
{
matched = true;
}
break;
case 2:
if (actualNumber > numberNeedle)
{
matched = true;
}
break;
}
}
}
if (matched)
{
PolytomiseNode(node, allChildren);
}
}
}
}
19
Source : Prune_node.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public static void Transform(ref TreeNode tree, Dictionary<string, object> parameterValues, Action<double> progressAction)
{
double position = (double)parameterValues["Position:"];
bool leaveParent = (bool)parameterValues["Leave one-child parent"];
int mode = (int)parameterValues["Mode:"];
bool keepNodeNames = (bool)parameterValues["Keep pruned node names"];
string storeAttributeName = (string)parameterValues["Attribute name:"];
if (mode == 0)
{
string[] nodeElements = (string[])parameterValues["Node:"];
TreeNode node = tree.GetLastCommonAncestor(nodeElements);
PruneNode(node, ref tree, position, leaveParent, keepNodeNames, storeAttributeName);
}
else if (mode == 1)
{
List<TreeNode> nodes = tree.GetChildrenRecursive();
string attributeName = (string)parameterValues["Attribute:"];
string attrType = (string)parameterValues["Attribute type:"];
string attrValue = (string)parameterValues["Value:"];
double numberNeedle = attrType == "Number" ? double.Parse(attrValue) : -1;
int comparisonType = attrType == "String" ? (int)parameterValues["Comparison type:"] : (int)parameterValues["Comparison type: "];
bool regex = (bool)parameterValues["Regex"];
StringComparison comparison = StringComparison.InvariantCulture;
RegexOptions options = RegexOptions.CultureInvariant;
switch (comparisonType)
{
case 0:
comparison = StringComparison.InvariantCulture;
options = RegexOptions.CultureInvariant;
break;
case 1:
comparison = StringComparison.InvariantCultureIgnoreCase;
options = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
break;
case 2:
comparison = StringComparison.CurrentCulture;
options = RegexOptions.None;
break;
case 3:
comparison = StringComparison.CurrentCultureIgnoreCase;
options = RegexOptions.IgnoreCase;
break;
}
Regex reg = regex ? new Regex(attrValue, options) : null;
for (int i = nodes.Count - 1; i >= 0; i--)
{
bool matched = false;
if (nodes[i].Attributes.TryGetValue(attributeName, out object attributeValue))
{
if (attrType == "String" && attributeValue is string actualValue)
{
if (regex)
{
if (reg.IsMatch(actualValue))
{
matched = true;
}
}
else
{
if (actualValue.Contains(attrValue, comparison))
{
matched = true;
}
}
}
else if (attrType == "Number" && attributeValue is double actualNumber)
{
switch (comparisonType)
{
case 0:
if (actualNumber == numberNeedle)
{
matched = true;
}
break;
case 1:
if (actualNumber < numberNeedle)
{
matched = true;
}
break;
case 2:
if (actualNumber > numberNeedle)
{
matched = true;
}
break;
}
}
}
if (matched)
{
PruneNode(nodes[i], ref tree, position, leaveParent, keepNodeNames, storeAttributeName);
}
}
}
}
19
Source : Replace_attribute.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public static void Transform(ref TreeNode tree, Dictionary<string, object> parameterValues, Action<double> progressAction)
{
List<TreeNode> nodes = tree.GetChildrenRecursive();
bool applyToChildren = (bool)parameterValues["Apply recursively to all children"];
string attributeName = (string)parameterValues["Attribute:"];
string attrType = (string)parameterValues["Attribute type:"];
string attrValue = (string)parameterValues["Value:"];
double numberNeedle = attrType == "Number" ? double.Parse(attrValue) : -1;
string replacementName = (string)parameterValues["Attribute: "];
string replacementType = (string)parameterValues["Attribute type: "];
string replacementValue = (string)parameterValues["Value: "];
int comparisonType = attrType == "String" ? (int)parameterValues["Comparison type:"] : (int)parameterValues["Comparison type: "];
bool regex = (bool)parameterValues["Regex"];
StringComparison comparison = StringComparison.InvariantCulture;
RegexOptions options = RegexOptions.CultureInvariant;
switch (comparisonType)
{
case 0:
comparison = StringComparison.InvariantCulture;
options = RegexOptions.CultureInvariant;
break;
case 1:
comparison = StringComparison.InvariantCultureIgnoreCase;
options = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
break;
case 2:
comparison = StringComparison.CurrentCulture;
options = RegexOptions.None;
break;
case 3:
comparison = StringComparison.CurrentCultureIgnoreCase;
options = RegexOptions.IgnoreCase;
break;
}
Regex reg = regex ? new Regex(attrValue, options) : null;
foreach (TreeNode node in nodes)
{
bool matched = false;
if (node.Attributes.TryGetValue(attributeName, out object attributeValue))
{
if (attrType == "String" && attributeValue is string actualValue)
{
if (regex)
{
if (reg.IsMatch(actualValue))
{
matched = true;
}
}
else
{
if (actualValue.Contains(attrValue, comparison))
{
matched = true;
}
}
}
else if (attrType == "Number" && attributeValue is double actualNumber)
{
switch (comparisonType)
{
case 0:
if (actualNumber == numberNeedle)
{
matched = true;
}
break;
case 1:
if (actualNumber < numberNeedle)
{
matched = true;
}
break;
case 2:
if (actualNumber > numberNeedle)
{
matched = true;
}
break;
}
}
}
if (matched)
{
string currentReplacementValue = replacementValue;
if (attrType == "String" && replacementType == "String" && (attributeName.Equals(replacementName, StringComparison.OrdinalIgnoreCase) || regex))
{
if (!regex)
{
currentReplacementValue = ((string)attributeValue).Replace(attrValue, replacementValue, comparison);
}
else
{
currentReplacementValue = reg.Replace(((string)attributeValue), replacementValue);
}
}
if (!applyToChildren)
{
if (replacementName == "Name" && replacementType == "String")
{
node.Name = currentReplacementValue;
}
else if (replacementName == "Support" && replacementType == "Number")
{
node.Support = double.Parse(currentReplacementValue);
}
else if (replacementName == "Length" && replacementType == "Number")
{
node.Length = double.Parse(currentReplacementValue);
}
else if (!string.IsNullOrEmpty(replacementType))
{
if (replacementType == "String")
{
node.Attributes[replacementName] = currentReplacementValue;
}
else if (replacementType == "Number")
{
node.Attributes[replacementName] = double.Parse(currentReplacementValue);
}
}
}
else
{
foreach (TreeNode child in node.GetChildrenRecursiveLazy())
{
if (replacementName == "Name" && replacementType == "String")
{
child.Name = currentReplacementValue;
}
else if (replacementName == "Support" && replacementType == "Number")
{
child.Support = double.Parse(currentReplacementValue);
}
else if (replacementName == "Length" && replacementType == "Number")
{
child.Length = double.Parse(currentReplacementValue);
}
else if (!string.IsNullOrEmpty(replacementType))
{
if (replacementType == "String")
{
child.Attributes[replacementName] = currentReplacementValue;
}
else if (replacementType == "Number")
{
child.Attributes[replacementName] = double.Parse(currentReplacementValue);
}
}
}
}
}
}
}
19
Source : FileCommand.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public override IEnumerable<(ConsoleTextSpan[], string)> GetCompletions(string partialCommand)
{
if (string.IsNullOrWhiteSpace(partialCommand))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("file ", ConsoleColor.Green) }, "file ");
string[] directories = Directory.GetDirectories(Directory.GetCurrentDirectory(), "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
else
{
partialCommand = partialCommand.Trim();
Regex reg = new Regex("^[A-Za-z]:$");
if (reg.IsMatch(partialCommand))
{
partialCommand = partialCommand + "\\";
}
partialCommand = partialCommand.Trim();
string directory = null;
directory = Path.GetDirectoryName(partialCommand);
if (directory == null)
{
reg = new Regex("^[A-Za-z]:\\\\$");
if (reg.IsMatch(partialCommand))
{
directory = partialCommand;
}
}
string actualDirectory = directory;
if (string.IsNullOrEmpty(actualDirectory))
{
actualDirectory = Directory.GetCurrentDirectory();
}
string fileName = Path.GetFileName(partialCommand);
string[] directories = Directory.GetDirectories(actualDirectory, fileName + "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(actualDirectory, fileName + "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
}
19
Source : OpenCommand.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public override IEnumerable<(ConsoleTextSpan[], string)> GetCompletions(string partialCommand)
{
if (string.IsNullOrWhiteSpace(partialCommand))
{
if (!string.IsNullOrEmpty(Program.InputFileName))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open", ConsoleColor.Green) }, "open ");
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("info", ConsoleColor.Yellow) }, "open info ");
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("with", ConsoleColor.Yellow) }, "open with ");
}
string[] directories = Directory.GetDirectories(Directory.GetCurrentDirectory(), "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
else
{
partialCommand = partialCommand.TrimStart();
StringBuilder firstWordBuilder = new StringBuilder();
foreach (char c in partialCommand)
{
if (!char.IsWhiteSpace(c))
{
firstWordBuilder.Append(c);
}
else
{
break;
}
}
string firstWord = firstWordBuilder.ToString();
if (firstWord.Equals("with", StringComparison.OrdinalIgnoreCase))
{
partialCommand = partialCommand.Substring(4).TrimStart();
foreach (FileTypeModule mod in Modules.FileTypeModules)
{
if (mod.Name.StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("with ", ConsoleColor.Yellow), new ConsoleTextSpan(mod.Name + " ", ConsoleColor.Blue) }, "open with " + mod.Name + " ");
}
}
foreach (FileTypeModule mod in Modules.FileTypeModules)
{
if (mod.Id.StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("with ", ConsoleColor.Yellow), new ConsoleTextSpan(mod.Id + " ", ConsoleColor.Blue) }, "open with " + mod.Id + " ");
}
}
}
else if (firstWord.Equals("info", StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("info", ConsoleColor.Yellow) }, "open info ");
}
else
{
if ("with".StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("with", ConsoleColor.Yellow) }, "open with ");
}
if ("info".StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("open ", ConsoleColor.Green), new ConsoleTextSpan("info", ConsoleColor.Yellow) }, "open info ");
}
Regex reg = new Regex("^[A-Za-z]:$");
if (reg.IsMatch(partialCommand))
{
partialCommand = partialCommand + "\\";
}
partialCommand = partialCommand.Trim();
string directory = null;
directory = Path.GetDirectoryName(partialCommand);
if (directory == null)
{
reg = new Regex("^[A-Za-z]:\\\\$");
if (reg.IsMatch(partialCommand))
{
directory = partialCommand;
}
}
string actualDirectory = directory;
if (string.IsNullOrEmpty(actualDirectory))
{
actualDirectory = Directory.GetCurrentDirectory();
}
string fileName = Path.GetFileName(partialCommand);
string[] directories = Directory.GetDirectories(actualDirectory, fileName + "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(actualDirectory, fileName + "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
}
}
19
Source : PDFCommand.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public override IEnumerable<(ConsoleTextSpan[], string)> GetCompletions(string partialCommand)
{
if (string.IsNullOrWhiteSpace(partialCommand))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("pdf", ConsoleColor.Green) }, "pdf ");
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("pdf ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "pdf stdout ");
string[] directories = Directory.GetDirectories(Directory.GetCurrentDirectory(), "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
else
{
partialCommand = partialCommand.TrimStart();
StringBuilder firstWordBuilder = new StringBuilder();
foreach (char c in partialCommand)
{
if (!char.IsWhiteSpace(c))
{
firstWordBuilder.Append(c);
}
else
{
break;
}
}
string firstWord = firstWordBuilder.ToString();
if (firstWord.Equals("stdout", StringComparison.OrdinalIgnoreCase))
{
partialCommand = partialCommand.Substring(4).TrimStart();
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("pdf ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "pdf stdout ");
}
else
{
if ("stdout".StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("pdf ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "pdf stdout ");
}
Regex reg = new Regex("^[A-Za-z]:$");
if (reg.IsMatch(partialCommand))
{
partialCommand = partialCommand + "\\";
}
partialCommand = partialCommand.Trim();
string directory = null;
directory = Path.GetDirectoryName(partialCommand);
if (directory == null)
{
reg = new Regex("^[A-Za-z]:\\\\$");
if (reg.IsMatch(partialCommand))
{
directory = partialCommand;
}
}
string actualDirectory = directory;
if (string.IsNullOrEmpty(actualDirectory))
{
actualDirectory = Directory.GetCurrentDirectory();
}
string fileName = Path.GetFileName(partialCommand);
string[] directories = Directory.GetDirectories(actualDirectory, fileName + "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(actualDirectory, fileName + "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
}
}
19
Source : SVGCommand.cs
with GNU Affero General Public License v3.0
from arklumpus
with GNU Affero General Public License v3.0
from arklumpus
public override IEnumerable<(ConsoleTextSpan[], string)> GetCompletions(string partialCommand)
{
if (string.IsNullOrWhiteSpace(partialCommand))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("svg", ConsoleColor.Green) }, "svg ");
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("svg ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "svg stdout ");
string[] directories = Directory.GetDirectories(Directory.GetCurrentDirectory(), "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.GetFileName(sr) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
else
{
partialCommand = partialCommand.TrimStart();
StringBuilder firstWordBuilder = new StringBuilder();
foreach (char c in partialCommand)
{
if (!char.IsWhiteSpace(c))
{
firstWordBuilder.Append(c);
}
else
{
break;
}
}
string firstWord = firstWordBuilder.ToString();
if (firstWord.Equals("stdout", StringComparison.OrdinalIgnoreCase))
{
partialCommand = partialCommand.Substring(4).TrimStart();
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("svg ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "svg stdout ");
}
else
{
if ("stdout".StartsWith(partialCommand, StringComparison.OrdinalIgnoreCase))
{
yield return (new ConsoleTextSpan[] { new ConsoleTextSpan("svg ", ConsoleColor.Green), new ConsoleTextSpan("stdout", ConsoleColor.Yellow) }, "svg stdout ");
}
Regex reg = new Regex("^[A-Za-z]:$");
if (reg.IsMatch(partialCommand))
{
partialCommand = partialCommand + "\\";
}
partialCommand = partialCommand.Trim();
string directory = null;
directory = Path.GetDirectoryName(partialCommand);
if (directory == null)
{
reg = new Regex("^[A-Za-z]:\\\\$");
if (reg.IsMatch(partialCommand))
{
directory = partialCommand;
}
}
string actualDirectory = directory;
if (string.IsNullOrEmpty(actualDirectory))
{
actualDirectory = Directory.GetCurrentDirectory();
}
string fileName = Path.GetFileName(partialCommand);
string[] directories = Directory.GetDirectories(actualDirectory, fileName + "*");
List<(ConsoleTextSpan[], string)> tbr = new List<(ConsoleTextSpan[], string)>();
foreach (string sr in directories)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Blue)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + Path.DirectorySeparatorChar));
}
string[] files = Directory.GetFiles(actualDirectory, fileName + "*");
foreach (string sr in files)
{
tbr.Add((new ConsoleTextSpan[]
{
new ConsoleTextSpan(Path.GetFileName(sr) + " ", ConsoleColor.Red)
}, this.PrimaryCommand + " " + Path.Combine(directory, Path.GetFileName(sr)) + " "));
}
tbr.Sort((a, b) => a.Item2.CompareTo(b.Item2));
foreach ((ConsoleTextSpan[], string) item in tbr)
{
yield return item;
}
}
}
}
19
Source : Permission.cs
with MIT License
from ASF-Framework
with MIT License
from ASF-Framework
public bool MatchApiTemplate(string requestPath)
{
if (ApiTemplateRegex == null)
this.ApiTemplateRegex = new Regex($"^{this.ApiTemplate}$");
return this.ApiTemplateRegex.IsMatch(requestPath);
}
19
Source : ValidationHelperExtensions.cs
with MIT License
from ASF-Framework
with MIT License
from ASF-Framework
public static bool IsDomainUrl(this string value)
{
string _regex = @"^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$";
Regex reg = new Regex(_regex);
if (!reg.IsMatch(value))
{
if (value == "localhost")
return true;
else
return false;
}
else
return true;
}
19
Source : ValidationHelperExtensions.cs
with MIT License
from ASF-Framework
with MIT License
from ASF-Framework
public static bool IsUrl(this string value)
{
string _regex = @"^((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?$";
Regex reg = new Regex(_regex);
if (!reg.IsMatch(value))
return false;
else
return true;
}
19
Source : AuthenticationController.cs
with GNU General Public License v3.0
from asimmon
with GNU General Public License v3.0
from asimmon
private async Task<string> GetUniqueUserName()
{
if (this.TryGetClaim(ClaimTypes.Name, out var githubUserName) && UserNameRegex.IsMatch(githubUserName))
{
var isAlreadyUsed = await this.Repository.IsUserNameAlreadyUsed(githubUserName).ConfigureAwait(false);
if (!isAlreadyUsed)
return githubUserName;
}
while (true)
{
var randomUserName = "Player" + Constants.Rng.Next(100000, 999999).ToString(CultureInfo.InvariantCulture);
var isAlreadyUsed = await this.Repository.IsUserNameAlreadyUsed(randomUserName).ConfigureAwait(false);
if (!isAlreadyUsed)
return randomUserName;
}
}
19
Source : ControlBase.cs
with GNU General Public License v2.0
from Asixa
with GNU General Public License v2.0
from Asixa
public static void OnlyNumber(object sender, TextCompositionEventArgs e)=>e.Handled = new Regex("[^0-9.-]+").IsMatch(e.Text);
19
Source : BitlyUrlShortener.cs
with GNU Affero General Public License v3.0
from asmejkal
with GNU Affero General Public License v3.0
from asmejkal
public bool IsShortened(string url) => LinkRegex.IsMatch(url);
19
Source : PolrUrlShortener.cs
with GNU Affero General Public License v3.0
from asmejkal
with GNU Affero General Public License v3.0
from asmejkal
public bool IsShortened(string url) => _linkRegex.IsMatch(url);
19
Source : HtmlDiff.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private void InsertTag(string tag, string cssClreplaced, List<string> words)
{
while (true)
{
if (words.Count == 0)
{
break;
}
string[] nonTags = ExtractConsecutiveWords(words, x => !Utils.IsTag(x));
string specialCaseTagInjection = string.Empty;
bool specialCaseTagInjectionIsBefore = false;
if (nonTags.Length != 0)
{
string text = Utils.WrapText(string.Join("", nonTags), tag, cssClreplaced);
_content.Append(text);
}
else
{
// Check if the tag is a special case
if (_specialCaseOpeningTagRegex.IsMatch(words[0]))
{
_specialTagDiffStack.Push(words[0]);
specialCaseTagInjection = "<ins clreplaced='mod'>";
if (tag == "del")
{
words.RemoveAt(0);
// following tags may be formatting tags as well, follow through
while (words.Count > 0 && _specialCaseOpeningTagRegex.IsMatch(words[0]))
{
words.RemoveAt(0);
}
}
}
else if (_specialCaseClosingTags.ContainsKey(words[0]))
{
var openingTag = _specialTagDiffStack.Count == 0 ? null : _specialTagDiffStack.Pop();
// If we didn't have an opening tag, and we don't have a match with the previous tag used
if (openingTag == null || openingTag != words.Last().Replace("/", ""))
{
// do nothing
}
else
{
specialCaseTagInjection = "</ins>";
specialCaseTagInjectionIsBefore = true;
}
if (tag == "del")
{
words.RemoveAt(0);
// following tags may be formatting tags as well, follow through
while (words.Count > 0 && _specialCaseClosingTags.ContainsKey(words[0]))
{
words.RemoveAt(0);
}
}
}
}
if (words.Count == 0 && specialCaseTagInjection.Length == 0)
{
break;
}
if (specialCaseTagInjectionIsBefore)
{
_content.Append(specialCaseTagInjection + String.Join("", ExtractConsecutiveWords(words, Utils.IsTag)));
}
else
{
_content.Append(String.Join("", ExtractConsecutiveWords(words, Utils.IsTag)) + specialCaseTagInjection);
}
}
}
19
Source : Utils.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private static bool IsOpeningTag(string item)
{
return openingTagRegex.IsMatch(item);
}
19
Source : Utils.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
public static bool IsWord(char text)
{
return wordRegex.IsMatch(new string(new[] { text }));
}
19
Source : Utils.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private static bool IsClosingTag(string item)
{
return closingTagTexRegex.IsMatch(item);
}
19
Source : Utils.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
public static bool IsWhiteSpace(string value)
{
return whitespaceRegex.IsMatch(value);
}
19
Source : DbcAnalizer.cs
with GNU General Public License v3.0
from astand
with GNU General Public License v3.0
from astand
public void TrimDbcRawStream(StringReader reader)
{
var line = String.Empty;
MessageDescriptor msgDesc = null;
while ((line = reader.ReadLine()) != null)
{
if (line.StartsWith("BO_ "))
{
if (msgDesc != null)
{
// this means that new message was met and previous message needs to be added to list
msgDesc.AddSignals(msgDesc.Signals.OrderBy(o => o.StartBit).ToList());
Messages.Add(msgDesc);
}
msgDesc = new MessageDescriptor();
if (!msgDesc.ParseVectorDbcLine(line))
{
// bad unparsing. clear message reference
msgDesc = null;
}
}
if (regSigStart.IsMatch(line) && (msgDesc != null))
{
var sig = new SignalBitsDesc();
sig.ParseFromVectorDbcString(line);
msgDesc.Signals.Add(sig);
}
else if (line.StartsWith("BA_ "))
{
// try parse this section for getting cycle time
var bastr = new AttrDescriptor();
if (bastr.ParseBA_(line) == true)
{
if (ba_.Where(b => b.MsgId == bastr.MsgId).FirstOrDefault() == null)
{
// there is no this message in collection yet
ba_.Add(bastr);
}
}
}
if (line.StartsWith("CM_ ") || commenter.IsCollectingData)
{
if (commenter.PreplacedString(line) == true)
{
if (commenter.Info.Type == CommentType.MessageComment)
{
var msg = Messages.Where(m => m.MessageId == commenter.Info.MsgId).FirstOrDefault();
if (msg != null)
{
// appropriate message was found
msg.CommentText = commenter.Info.Text;
}
}
else if (commenter.Info.Type == CommentType.SignalComment)
{
var msg = Messages.Where(m => m.MessageId == commenter.Info.MsgId).FirstOrDefault();
if (msg != null)
{
// appropriate message was found
var sig = msg.Signals.Where(s => s.FieldName == commenter.Info.SigName).FirstOrDefault();
if (sig != null)
{
sig.CommentText = commenter.Info.Text;
if (IsRollingCounterCodeAvailalbe && sig.CommentText.Contains(RollingCounterMatch))
{
if (msg.RollSig == null)
msg.RollSig = sig;
}
else if (IsChecksumMatchCodeAvailable && sig.CommentText.Contains(ChecksumMatch))
{
if (msg.CsmSig == null)
{
msg.CsmType = "kCRCUndefined";
if (sig.CommentText.Contains("CRC8_SAEJ1850"))
{
msg.CsmType = "kSAEJ1850";
}
else if (sig.CommentText.Contains("XOR8_Generic"))
{
msg.CsmType = "kXOR8";
}
else if (sig.CommentText.Contains("XOR4_generic") || sig.CommentText.Contains("XOR4_SAS"))
{
msg.CsmType = "kXOR4";
}
else if (sig.CommentText.Contains("XOR"))
{
// common case for XOR-base algorythms
msg.CsmType = "kXOR8";
}
msg.CsmSig = sig;
}
}
}
}
}
}
}
else if (line.StartsWith("VAL_ "))
{
valuator.PreplacedString(line);
var msg = Messages.Where(m => m.MessageId == valuator.MsgId).FirstOrDefault();
if (msg != null)
{
// appropriate message was found
var sig = msg.Signals.Where(s => s.FieldName == valuator.SigName).FirstOrDefault();
if (sig != null)
{
sig.ValueText = valuator.Text;
}
}
}
Messages = Messages.OrderBy(m => m.MessageId).ToList();
}
if (msgDesc != null)
{
msgDesc.Signals = msgDesc.Signals.OrderBy(o => o.StartBit).ToList();
Messages.Add(msgDesc);
}
foreach (var ba in ba_)
{
// update all the messages with parsed succesfully cycle time
var msg = Messages.Where(d => d.MessageId == ba.MsgId).FirstOrDefault();
if (msg != null)
{
msg.CycTime = ba.CycTime;
}
}
}
19
Source : IpAddressToStringConverter.cs
with The Unlicense
from astenlund
with The Unlicense
from astenlund
public object? ConvertBack(object? value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
if (!(value is string str))
return Binding.DoNothing;
if (str == "")
return null;
if (!_regex.IsMatch(str))
return Binding.DoNothing;
return IPAddress.TryParse(str, out var result)
? result
: Binding.DoNothing;
}
19
Source : ListViewColumnSorter.cs
with GNU General Public License v3.0
from audiamus
with GNU General Public License v3.0
from audiamus
private bool isWholeNumber (string strNumber) {
Regex wholePattern = new Regex (@"^\d+$");
return wholePattern.IsMatch (strNumber);
}
19
Source : PropertiesLoader.cs
with Apache License 2.0
from authlete
with Apache License 2.0
from authlete
static string ReadEffectiveLine(TextReader reader)
{
// Skip blank lines and comment lines.
string line = SkipIgnorableLines(reader);
if (line == null)
{
// No more line.
return null;
}
// Remove leading white spaces if any.
line = RemoveLeadingWhiteSpaces(line);
// If the line terminator is not escaped by '\'.
if (CONTINUING_LINE_PATTERN.IsMatch(line) == false)
{
// No need to concatenate the next line.
return line;
}
var builder = new StringBuilder();
// Remove the backslash at the end and append the
// resultant string.
builder.Append(RemoveLastChar(line));
while (true)
{
line = reader.ReadLine();
// If the end of the stream was reached.
if (line == null)
{
break;
}
// Ignore leading white spaces as the spec requires.
line = RemoveLeadingWhiteSpaces(line);
// If the line terminator is not escaped by '\'.
if (CONTINUING_LINE_PATTERN.IsMatch(line) == false)
{
// Append the line as is.
builder.Append(line);
// And this is the end of the logical line.
break;
}
// Remove the backslash at the end and append the
// resultant string.
builder.Append(RemoveLastChar(line));
}
return builder.ToString();
}
19
Source : PropertiesLoader.cs
with Apache License 2.0
from authlete
with Apache License 2.0
from authlete
static string SkipIgnorableLines(TextReader reader)
{
while (true)
{
// Read one line.
string line = reader.ReadLine();
// If the end of the stream was reached.
if (line == null)
{
// No more line.
return null;
}
// If the line is ignorable.
if (IGNORABLE_LINE_PATTERN.IsMatch(line))
{
// Skip the line.
continue;
}
// Found a non-ignorable line.
return line;
}
}
19
Source : MatchingTests.cs
with MIT License
from AutomataDotNet
with MIT License
from AutomataDotNet
private void replacedertIsMatchesAgree(System.Text.RegularExpressions.Regex r, Regex sr, string input, bool expected)
{
replacedert.AreEqual(expected, r.IsMatch(input), $"Unexpected result. Pattern:{r} Input:{input}");
replacedert.AreEqual(r.IsMatch(input), sr.IsMatch(input), $"Mismatch with System.Text.RegularExpressions. Pattern:{r} Input:{input}");
}
See More Examples