100+ results for 'regex ipv6'
Not the results you expected?
Utilities.cs (https://github.com/Microsoft/vscode-mono-debug.git) C# · 191 lines
21 private const string WHERE = "where";
23 private static readonly Regex VARIABLE = new Regex(@"\{(\w+)\}");
25 private static char[] ARGUMENT_SEPARATORS = new char[] { ' ', '\t' };
76 /*
77 * Resolve hostname, dotted-quad notation for IPv4, or colon-hexadecimal notation for IPv6 to IPAddress.
78 * Returns null on failure.
79 */
tests.py (http://googleappengine.googlecode.com/svn/trunk/) Python · 159 lines
123 to use for the inline formset, we should get an exception.
124 """
125 self.assertRaisesRegexp(Exception,
126 "<class 'regressiontests.inline_formsets.models.Child'> has more than 1 ForeignKey to <class 'regressiontests.inline_formsets.models.Parent'>",
127 inlineformset_factory, Parent, Child
143 exception.
144 """
145 self.assertRaisesRegexp(Exception,
146 "<class 'regressiontests.inline_formsets.models.Child'> has no field named 'test'",
147 inlineformset_factory, Parent, Child, fk_name='test'
PageParser.cs (https://mobileflares.svn.codeplex.com/svn) C# · 140 lines
41 {
42 if (content == null) getFile();
43 match = Regex.Match(content, RegTable);
44 if (!match.Success)
45 {
55 int index = 0;
56 int count = 0;
57 while((match = Regex.Match(table, RegFlare)).Success){
58 Group g = match.Groups[1];
59 //Console.WriteLine("--------------------\n" + g + "\n--------------------\n");
ApplyCssScopes.cs (https://gitlab.com/dotnetfoundation/sdk) C# · 152 lines
126 var razorItem = !string.IsNullOrWhiteSpace(explicitRazorItem) ?
127 explicitRazorItem :
128 Regex.Replace(scopedCssCandidate.ItemSpec, candidateMatchPattern, replacementExpression, RegexOptions.IgnoreCase);
130 if (string.Equals(itemCandidate.ItemSpec, razorItem, StringComparison.OrdinalIgnoreCase))
Extensions.cs (https://github.com/spodskubka/RemoteTerminal.git) C# · 195 lines
174 private static Regex _rehost = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$", RegexOptions.IgnoreCase);
176 private static Regex _reIPv6 = new Regex(@"^(((?=(?>.*?::)(?!.*::)))(::)?([0-9A-F]{1,4}::?){0,5}|([0-9A-F]{1,4}:){6})(\2([0-9A-F]{1,4}(::?|$)){0,2}|((25[0-5]|(2[0-4]|1\d|[1-9])?\d)(\.|$)){4}|[0-9A-F]{1,4}:[0-9A-F]{1,4})(?<![^:]:|\.)\z", RegexOptions.IgnoreCase);
178 internal static bool IsValidHost(this string value)
187 return true;
189 if (_reIPv6.Match(value).Success)
190 return true;
RegexMatchTests4.cs (https://github.com/EricWhiteDev/corefx.git) C# · 345 lines
NetworkAddressChange.OSX.cs (https://gitlab.com/0072016/0072016-corefx-) C# · 188 lines
22 private static NetworkAddressChangedEventHandler s_addressChangedSubscribers;
24 // The dynamic store. We listen to changes in the IPv4 and IPv6 address keys.
25 // When those keys change, our callback below is called (OnAddressChanged).
26 private static SafeCreateHandle s_dynamicStoreRef;
91 using (SafeCreateHandle compAnyRegexString = Interop.CoreFoundation.CFStringCreateWithCString("[^/]+"))
92 using (SafeCreateHandle entNetIpv4String = Interop.CoreFoundation.CFStringCreateWithCString("IPv4"))
93 using (SafeCreateHandle entNetIpv6String = Interop.CoreFoundation.CFStringCreateWithCString("IPv6"))
94 {
95 if (dynamicStoreDomainStateString.IsInvalid || compAnyRegexString.IsInvalid
96 || entNetIpv4String.IsInvalid || entNetIpv6String.IsInvalid)
97 {
98 s_dynamicStoreRef.Dispose();
103 using (SafeCreateHandle ipv4Pattern = Interop.SystemConfiguration.SCDynamicStoreKeyCreateNetworkServiceEntity(
104 dynamicStoreDomainStateString.DangerousGetHandle(),
105 compAnyRegexString.DangerousGetHandle(),
106 entNetIpv4String.DangerousGetHandle()))
107 using (SafeCreateHandle ipv6Pattern = Interop.SystemConfiguration.SCDynamicStoreKeyCreateNetworkServiceEntity(
WxManager.cs (https://github.com/siteserver/cms.git) C# · 137 lines
79 {
80 var startIndex = ex.JsonResult.errmsg.IndexOf("invalid ip ", StringComparison.Ordinal) + 11;
81 var endIndex = ex.JsonResult.errmsg.IndexOf(" ipv6", StringComparison.Ordinal);
82 var ip = ex.JsonResult.errmsg.Substring(startIndex, endIndex - startIndex);
83 errorMessage = $"调用接口的IP地址不在白名单中,请进入微信公众平台,将本服务器的IP地址 {ip} 添加至白名单";
108 private string SaveImages(string content)
109 {
110 var originalImageSrcs = RegexUtils.GetOriginalImageSrcs(content);
111 foreach (var originalImageSrc in originalImageSrcs)
112 {
AutoWebProxyScriptEngine.cs (https://github.com/pruiz/mono.git) C# · 181 lines
74 builder.Host = "127.0.0.1";
75 uri = builder.Uri;
76 } else if (IPAddress.IPv6Any.Equals (ip)) {
77 UriBuilder builder = new UriBuilder (uri);
78 builder.Host = "[::1]";
165 }
167 // Takes an ArrayList of fileglob-formatted strings and returns an array of Regex-formatted strings
168 static ArrayList CreateBypassList (ArrayList al)
169 {
172 {
173 result [c] = "^" +
174 Regex.Escape (result [c]).Replace (@"\*", ".*").Replace (@"\?", ".") +
175 "$";
176 }
CompletionRequest.java
(https://jedit.svn.sourceforge.net/svnroot/jedit)
Java · 219 lines
✨ Summary
This Java class, CompletionRequest
, is part of a CSS editor’s auto-completion feature. It analyzes user input and suggests possible completions based on CSS properties, units, and values. The class uses regular expressions to parse the input text and determine whether it matches certain patterns, allowing it to provide relevant suggestions for completion.
This Java class, CompletionRequest
, is part of a CSS editor’s auto-completion feature. It analyzes user input and suggests possible completions based on CSS properties, units, and values. The class uses regular expressions to parse the input text and determine whether it matches certain patterns, allowing it to provide relevant suggestions for completion.
IndicatorViewModel.cs (https://github.com/CrowdStrike/falcon-orchestrator.git) C# · 98 lines
48 items.Add(new SelectListItem() { Text = "MD5", Value = "MD5" });
49 items.Add(new SelectListItem() { Text = "IPV4", Value = "IPV4" });
50 items.Add(new SelectListItem() { Text = "IPV6", Value = "IPV6" });
51 return items;
52 }
86 }
88 if (this.Type.ToUpper().Equals("IPV4") && !Regex.IsMatch(this.Value,@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"))
89 {
90 yield return new ValidationResult("Not a valid IPv4 address", new[] { "Value" });
DismImageService.cs (https://github.com/WOA-Project/WOA-Deployer.git) C# · 117 lines
19 public class DismImageService : ImageServiceBase
20 {
21 private readonly Regex percentRegex = new Regex(@"(\d*.\d*)%");
23 public DismImageService(IFileSystemOperations fileSystemOperations) : base(fileSystemOperations)
96 }
98 var matches = percentRegex.Match(dismOutput);
100 if (matches.Success)
LargeFileTest.cs (https://github.com/Microsoft/BuildXL.git) C# · 117 lines
IIPAddress.cs (https://github.com/Vanaheimr/Hermod.git) C# · 160 lines
33 //ToDo: Better do this by hand!
34 public static Regex IPv4AddressRegExpr = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
36 //ToDo: Better do this by hand!
37 public static Regex IPv6AddressRegExpr = new Regex(@"(([a-f0-9:]+:+)+[a-f0-9]+)");
88 public static Boolean IsIPv6(String IPAddress)
89 => IPAddress.IsNotNullOrEmpty() &&
90 IPv6AddressRegExpr.IsMatch(IPAddress?.Trim());
92 public static Boolean IsIPv6(HTTPHostname Hostname)
subject.aspx.cs (https://abaccn.svn.codeplex.com/svn) C# · 122 lines
95 if (dept.CommonSubjects != string.Empty)
96 {
97 string t = Regex.Replace(dept.CommonSubjects, @"\r\n", "</td></tr><tr><td>");
98 t = Regex.Replace(t, @"\t{2,}", "</td><td class='last'>");
99 t = Regex.Replace(t, "(First|Second|Third|Fourth) (Semester|Year)", "<em>$1 $2</em>");
100 t = Regex.Replace(t, "?(?|?|?|?)(??|??)", "<em>?$1$2</em>");
JScriptException.cs (https://github.com/cschlote/mono.git) C# · 180 lines
ProcessorsDescriptor.cs (https://github.com/elastic/elasticsearch-net.git) C# · 181 lines
70 /// based on data from the Maxmind databases.
71 /// This processor adds this information by default under the geoip field.
72 /// The geoip processor can resolve both IPv4 and IPv6 addresses.
73 /// </summary>
74 /// <remarks>
138 /// The user_agent processor extracts details from the user agent string a browser sends with its web requests.
139 /// This processor adds this information by default under the user_agent field.
140 /// The ingest-user-agent plugin ships by default with the regexes.yaml made available by
141 /// uap-java with an Apache 2.0 license.
142 /// </summary>
jedit_keys.props (https://jedit.svn.sourceforge.net/svnroot/jedit) Unknown · 235 lines
TemplateDir.java
(https://jedit.svn.sourceforge.net/svnroot/jedit)
Java · 229 lines
✨ Summary
This Java code defines a TemplateDir
class, which represents a directory within a templates hierarchy. It scans the templates directory, creates a tree of template files and directories, and generates a string representation of the hierarchy for debugging purposes. The class provides methods to access and manipulate the template directory structure, including adding menu items and retrieving child nodes.
This Java code defines a TemplateDir
class, which represents a directory within a templates hierarchy. It scans the templates directory, creates a tree of template files and directories, and generates a string representation of the hierarchy for debugging purposes. The class provides methods to access and manipulate the template directory structure, including adding menu items and retrieving child nodes.
26 import java.util.*;
27 import javax.swing.tree.TreeNode;
28 import gnu.regexp.*;
29 import org.gjt.sp.jedit.*;
30 import org.gjt.sp.jedit.gui.EnhancedMenuItem;
77 }
78 }
79 } catch (gnu.regexp.REException ree) {
80 Log.log(Log.ERROR,this,jEdit.getProperty("plugin.TemplatesPlugin.error.bad-backup-filter"));
81 // System.out.println("Templates: Bad RegExp creating backup filter.");
83 }
85 private static void createBackupFilter() throws gnu.regexp.REException {
86 String exp = jEdit.getProperty("backup.prefix") +
87 "\\S+" +
Constants.cs (https://github.com/JamesNK/Newtonsoft.Json.Schema.git) C# · 161 lines
105 public const string Time = "time";
106 public const string UtcMilliseconds = "utc-millisec";
107 public const string Regex = "regex";
108 public const string Color = "color";
109 public const string Style = "style";
113 public const string UriTemplate = "uri-template";
114 public const string JsonPointer = "json-pointer";
115 public const string IPv6 = "ipv6";
116 public const string IPv4 = "ipv4";
117 public const string Email = "email";
ReplaceForm.Designer.cs (https://github.com/otykier/TabularEditor.git) C# · 184 lines
33 this.chkMatchCase = new System.Windows.Forms.CheckBox();
34 this.chkWholeWord = new System.Windows.Forms.CheckBox();
35 this.chkRegEx = new System.Windows.Forms.CheckBox();
36 this.txtPattern = new System.Windows.Forms.TextBox();
37 this.txtReplaceWith = new System.Windows.Forms.TextBox();
83 this.chkWholeWord.UseVisualStyleBackColor = true;
84 //
85 // chkRegEx
86 //
87 this.chkRegEx.AutoSize = true;
88 this.chkRegEx.Location = new System.Drawing.Point(269, 35);
89 this.chkRegEx.Name = "chkRegEx";
90 this.chkRegEx.Size = new System.Drawing.Size(144, 17);
91 this.chkRegEx.TabIndex = 5;
92 this.chkRegEx.Text = "Use Regular Expressions";
MovieService.cs (https://github.com/LordTakeshiXVII/SeriesSelector.git) C# · 117 lines
FtpClientHttp11Proxy.cs (https://github.com/robinrodricks/FluentFTP.git) C# · 210 lines
141 LogLine(FtpTraceLevel.Info, buf);
143 if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success) {
144 reply.Code = m.Groups["code"].Value;
145 reply.Message = m.Groups["message"].Value;
183 LogLine(FtpTraceLevel.Info, buf);
185 if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success) {
186 reply.Code = m.Groups["code"].Value;
187 reply.Message = m.Groups["message"].Value;
MultipleHostsRangeValidator.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 93 lines
20 {
21 // 192.168.0.1
22 if (Regex.IsMatch(ipHostOrRange, RegexHelper.IPv4AddressRegex))
23 continue;
25 // 192.168.0.0/24
26 if (Regex.IsMatch(ipHostOrRange, RegexHelper.IPv4AddressCidrRegex))
27 continue;
71 // 2001:db8:85a3::8a2e:370:7334
72 if (Regex.IsMatch(ipHostOrRange, RegexHelper.IPv6AddressRegex))
73 continue;
HostRangeHelper.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 218 lines
39 // 192.168.0.0/24 or 192.168.0.0/255.255.255.0
40 if (Regex.IsMatch(ipOrRange, RegexHelper.IPv4AddressCidrRegex) || Regex.IsMatch(ipOrRange, RegexHelper.IPv4AddressSubnetmaskRegex))
41 {
42 var network = IPNetwork.Parse(ipOrRange);
128 // 2001:db8:85a3::8a2e:370:7334
129 if (Regex.IsMatch(ipOrRange, RegexHelper.IPv6AddressRegex))
130 {
131 bag.Add(IPAddress.Parse(ipOrRange));
190 }
191 // example.com/24 or example.com/255.255.255.128
192 else if (Regex.IsMatch(ipHostOrRange, RegexHelper.HostnameCidrRegex) || Regex.IsMatch(ipHostOrRange, RegexHelper.HostnameSubnetmaskRegex))
193 {
194 var hostAndSubnet = ipHostOrRange.Split('/');
FormCommitTemplateSettings.Designer.cs (https://github.com/XelaRellum/gitextensions.git) C# · 432 lines
42 this.labelSecondLineEmpty = new System.Windows.Forms.Label();
43 this.checkBoxSecondLineEmpty = new System.Windows.Forms.CheckBox();
44 this.labelRegExCheck = new System.Windows.Forms.Label();
45 this._NO_TRANSLATE_textBoxCommitValidationRegex = new System.Windows.Forms.TextBox();
221 // labelRegExCheck
222 //
223 this.labelRegExCheck.Anchor = System.Windows.Forms.AnchorStyles.Left;
224 this.labelRegExCheck.AutoSize = true;
225 this.labelRegExCheck.Location = new System.Drawing.Point(3, 85);
226 this.labelRegExCheck.Name = "labelRegExCheck";
227 this.labelRegExCheck.Size = new System.Drawing.Size(345, 15);
228 this.labelRegExCheck.TabIndex = 7;
229 this.labelRegExCheck.Text = "Commit must match following RegEx (Empty = check disabled):";
230 //
231 // _NO_TRANSLATE_textBoxCommitValidationRegex
234 this._NO_TRANSLATE_textBoxCommitValidationRegex.Location = new System.Drawing.Point(450, 81);
235 this._NO_TRANSLATE_textBoxCommitValidationRegex.Name = "_NO_TRANSLATE_textBoxCommitValidationRegex";
236 this._NO_TRANSLATE_textBoxCommitValidationRegex.Size = new System.Drawing.Size(233, 23);
ArgumentParser.cs (https://github.com/abhishek-kumar/AIGA.git) C# · 89 lines
cHelper.cs (https://dbcopytool.svn.codeplex.com/svn) C# · 103 lines
26 public static bool CheckFilePathRegex(string sFilepath)
27 {
28 //check if dirs are dirs
29 Regex reFoldername = new Regex("^[A-Za-z]:\\\\(.)*(\\\\)*$");
31 if (!reFoldername.IsMatch(sFilepath) || !sFilepath.EndsWith("\\"))
72 if (IpA[0].AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
73 {
74 returnIP = IpA[0].ToString().Replace(":", "-").Replace("%", "s") + ".ipv6-literal.net";
75 }
76 else
FindForm.designer.cs (https://github.com/jcaillon/3P.git) C# · 146 lines
32 this.btFindNext = new System.Windows.Forms.Button();
33 this.tbFind = new System.Windows.Forms.TextBox();
34 this.cbRegex = new System.Windows.Forms.CheckBox();
35 this.cbMatchCase = new System.Windows.Forms.CheckBox();
36 this.label1 = new System.Windows.Forms.Label();
67 this.tbFind.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbFind_KeyPress);
68 //
69 // cbRegex
70 //
71 this.cbRegex.AutoSize = true;
72 this.cbRegex.Location = new System.Drawing.Point(249, 38);
73 this.cbRegex.Name = "cbRegex";
74 this.cbRegex.Size = new System.Drawing.Size(57, 17);
75 this.cbRegex.TabIndex = 3;
76 this.cbRegex.Text = "Regex";
77 this.cbRegex.UseVisualStyleBackColor = true;
Pop3Client.cs (https://filedownloader.svn.codeplex.com/svn) C# · 381 lines
97 // occurs when the host IP Address is not compatible
98 // with the address family
99 // (typical in the IPv6 case).
101 foreach (IPAddress address in hostEntry.AddressList)
246 // if values returned ...
247 if (Regex.Match(returned,
248 @"^.*\+OK[ | ]+([0-9]+)[ | ]+.*$").Success)
249 {
250 // get number of emails ...
251 count = long.Parse(Regex
252 .Replace(returned.Replace("\r\n", "")
253 , @"^.*\+OK[ | ]+([0-9]+)[ | ]+.*$", "$1"));
GelfLogger.cs (https://github.com/mattwcole/gelf-extensions-logging.git) C# · 196 lines
11 public class GelfLogger : ILogger
12 {
13 private static readonly Regex AdditionalFieldKeyRegex = new(@"^[\w\.\-]*$", RegexOptions.Compiled);
14 private static readonly HashSet<string> ReservedAdditionalFieldKeys = new()
15 {
103 if (field.Key != "{OriginalFormat}")
104 {
105 if (AdditionalFieldKeyRegex.IsMatch(field.Key) && !ReservedAdditionalFieldKeys.Contains(field.Key))
106 {
107 yield return field;
MainView.cs (https://magtools.svn.codeplex.com/svn) C# · 502 lines
210 InventorySearch = view != null ? (HudTextBox)view["InventorySearch"] : new HudTextBox();
211 InventorySearch.Hit += (s, e) => { if (InventorySearch.Text == "regex search string") InventorySearch.Text = String.Empty; };
212 InventoryList = view != null ? (HudList)view["InventoryList"] : new HudList();
213 InventoryItemText = view != null ? (HudStaticText)view["InventoryItemText"] : new HudStaticText();
General.cs
(http://xe8tmw7c.googlecode.com/svn/)
C# · 306 lines
✨ Summary
This C# code defines a class that parses and generates text representations of game-related data, such as towers and monsters. It uses regular expressions to extract relevant information from input strings and constructs corresponding objects with properties like position, level, and type. The generated text can be used for display or storage purposes in a game or simulation.
This C# code defines a class that parses and generates text representations of game-related data, such as towers and monsters. It uses regular expressions to extract relevant information from input strings and constructs corresponding objects with properties like position, level, and type. The generated text can be used for display or storage purposes in a game or simulation.
135 public static Kore.Structures.Monster parseMonster(string chaine)
136 {
137 Regex msntre = new Regex("([a-zA-Z0-9])([0-9]+,[0-9]+);([0-9]{1});([0-9]{1,2})");
138 GroupCollection cc = msntre.Match(chaine).Groups;
245 public static Kore.Structures.Tower parseTower(string chaine)
246 {
247 Regex msntre = new Regex("([a-zA-Z0-9])([0-9]+,[0-9]+);([0-9]{1,2})");
248 GroupCollection cc = msntre.Match(chaine).Groups;
Template.cs (https://bitbucket.org/jdeselms/magenoco.git) C# · 155 lines
22 private readonly Template _fileNameTemplateOrNull;
24 private static Regex _tokenRegex;
25 private static Regex _childTokenRegex;
29 _name = name;
30 _appliesTo = appliesTo == null ? new string[0] : appliesTo.Split(',');
31 _tokenRegex = new Regex("\\<\\<([a-zA-Z_][a-zA-Z0-9_]*)(\\.[a-zA-Z_][a-zA-Z0-9_]*)?\\>\\>");
32 _childTokenRegex = new Regex("{{([a-zA-Z_][a-zA-Z0-9_]*)(\\.[a-zA-Z_][a-zA-Z0-9_]*)?}}");
134 {
135 HashSet<TextToken> matches = new HashSet<TextToken>();
136 foreach (Match match in _tokenRegex.Matches(_text))
137 {
138 matches.Add(new TextToken(match.Value.Substring(2, match.Value.Length-4)));
145 {
146 HashSet<ChildToken> matches = new HashSet<ChildToken>();
147 foreach (Match match in _childTokenRegex.Matches(_text))
148 {
149 matches.Add(new ChildToken(match.Value));
SystemTransactionFixtureBase.cs (https://github.com/RogerKratz/nhibernate-core.git) C# · 154 lines
39 }
40 // Purge any previous enlist
41 connectionString = Regex.Replace(
42 connectionString, $"[^;\"a-zA-Z]*{autoEnlistmentKeywordPattern}=[^;\"]*;?", string.Empty,
43 RegexOptions.IgnoreCase);
44 // Avoid redundant semi-colon
45 connectionString = Regex.Replace(
46 connectionString, $";[/s]*$", string.Empty,
47 RegexOptions.IgnoreCase);
AboutBox.Designer.cs (https://regexplore.svn.codeplex.com/svn) C# · 87 lines
ImageFlasher.cs (https://github.com/WOA-Project/WOA-Deployer.git) C# · 106 lines
Sprite.cs (https://github.com/Fiolek-/Kingdoms-Clash.NET.git) C# · 233 lines
17 {
18 #region Private fields
19 private static Regex AnimationInfoRegex = new Regex(@"(\d+),(\d+)x(\d+),(\d+[\.]?\d*)", RegexOptions.Compiled);
21 private ITexture _Texture = null;
208 this._FrameSizePixels = this.Texture.Size;
210 var match = AnimationInfoRegex.Match(this.Texture.UserData);
211 if (match.Success) //Mamy informacje o animacji
212 {
IniConfig.cs (https://github.com/UbitUmarov/Ubit-opensim.git) C# · 98 lines
43 static IniFile()
44 {
45 _iniKeyValuePatternRegex = new Regex(
46 @"((\s)*(?<Key>([^\=^\s^\n]+))[\s^\n]*
47 # key part (surrounding whitespace stripped)
50 # value part (surrounding whitespace stripped)
51 ",
52 RegexOptions.IgnorePatternWhitespace |
53 RegexOptions.Compiled |
54 RegexOptions.CultureInvariant);
55 }
57 private static Regex _iniKeyValuePatternRegex;
59 public IniFile(string iniFileName)
ConstraintBuilder.cs (https://github.com/letssellsomebananas/mono.git) C# · 436 lines
UriPatternService.cs (http://exyus.googlecode.com/svn/trunk/) C# · 185 lines
ReplaceForm.designer.cs
(http://open-webkit-sharp.googlecode.com/svn/)
C# · 198 lines
✨ Summary
This C# code defines a Windows Form application for finding and replacing text in a given string. The form allows users to input a search pattern, select options such as case sensitivity and whole word matching, and then replace the found text with a new value. It includes buttons for finding the next occurrence, closing the form, and performing the replacement.
This C# code defines a Windows Form application for finding and replacing text in a given string. The form allows users to input a search pattern, select options such as case sensitivity and whole word matching, and then replace the found text with a new value. It includes buttons for finding the next occurrence, closing the form, and performing the replacement.
32 this.btFindNext = new System.Windows.Forms.Button();
33 this.tbFind = new System.Windows.Forms.TextBox();
34 this.cbRegex = new System.Windows.Forms.CheckBox();
35 this.cbMatchCase = new System.Windows.Forms.CheckBox();
36 this.label1 = new System.Windows.Forms.Label();
72 this.tbFind.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbFind_KeyPress);
73 //
74 // cbRegex
75 //
76 this.cbRegex.AutoSize = true;
77 this.cbRegex.Location = new System.Drawing.Point(273, 38);
78 this.cbRegex.Name = "cbRegex";
79 this.cbRegex.Size = new System.Drawing.Size(57, 17);
80 this.cbRegex.TabIndex = 3;
81 this.cbRegex.Text = "Regex";
82 this.cbRegex.UseVisualStyleBackColor = true;
NewAzureFirewallNatRuleCommand.cs (https://github.com/Azure/azure-powershell.git) C# · 184 lines
155 private void ValidateIsSingleIpNotRange(string ipStr)
156 {
157 var singleIpRegEx = new Regex("^((\\d){1,3}\\.){3}((\\d){1,3})$");
159 if (!singleIpRegEx.IsMatch(ipStr))
174 private void ValidateIsFqdn(string fqdn)
175 {
176 var fqdnRegEx = new Regex("^[a-zA-Z0-9]+(([a-zA-Z0-9_\\-]*[a-zA-Z0-9]+)*\\.)*(?:[a-zA-Z0-9]{2,})$");
178 if (!fqdnRegEx.IsMatch(fqdn))
JumonyReader.cs (https://jumony.svn.codeplex.com/svn) C# · 295 lines
18 /// 用于匹配 HTML 标签的正则表达式对象
19 /// </summary>
20 protected static readonly Regex tagRegex = new Regulars.HtmlTag();
121 {
123 Regex endTagRegex = HtmlSpecification.GetEndTagRegex( elementName );
124 var endTagMatch = endTagRegex.Match( HtmlText, index );
144 var match = tagRegex.Match( HtmlText, index );
146 if ( !match.Success )//如果不再有标签的匹配
CharIndexed.java
(https://jedit.svn.sourceforge.net/svnroot/jedit)
Java · 66 lines
✨ Summary
This Java interface defines a common interface for different types of source text, such as strings, buffers, and input streams. It provides methods to access characters at specific positions in the text, including moving the cursor position and checking if it’s valid. The interface also includes constants for handling out-of-range indices.
This Java interface defines a common interface for different types of source text, such as strings, buffers, and input streams. It provides methods to access characters at specific positions in the text, including moving the cursor position and checking if it’s valid. The interface also includes constants for handling out-of-range indices.
ApplyCssScopes.cs (https://github.com/aspnet/AspNetCore.git) C# · 96 lines
38 var razorComponent = !string.IsNullOrWhiteSpace(explicitRazorcomponent) ?
39 explicitRazorcomponent :
40 Regex.Replace(scopedCssCandidate.ItemSpec, "(.*)\\.razor\\.css$", "$1.razor", RegexOptions.IgnoreCase);
42 if (string.Equals(componentCandidate.ItemSpec, razorComponent, StringComparison.OrdinalIgnoreCase))
InternetTest.cs (https://github.com/rscarvalho/FakerSharp.git) C# · 206 lines
NetworkBaseCmdlet.cs (https://github.com/Azure/azure-powershell.git) C# · 130 lines
28 public const string IPv4 = "IPv4";
29 public const string IPv6 = "IPv6";
30 public const string All = "All";
31 public const string DisabledRuleGroupsAlias = "DisabledRuleGroups";
89 Regex r = (instanceName == null && version == null)
90 ? new Regex(@"(.*?)/" + resourceName + @"/(?<rgname>\S+)", RegexOptions.IgnoreCase)
91 : new Regex(@"(.*?)/" + resourceName + @"/(?<rgname>\S+)/" + instanceName + @"/(?<instanceId>\S+)", RegexOptions.IgnoreCase);
RegexPatterns.cs (https://github.com/ghost1372/HandyControls.git) C# · 165 lines
AzodTestConfig.cs (https://github.com/microsoft/WindowsProtocolTestSuites.git) C# · 477 lines
414 else
415 {
416 content = Regex.Replace(content, "{" + property.Name + "}", property.GetValue(this, null).ToString());
417 }
418 }
435 clientRole.ComputerName = ClientComputerName;
436 clientRole.Ipv4 = ClientComputerIp;
437 clientRole.Ipv6 = null;
438 clientRole.MAC = null;
442 APRole.ComputerName = ApplicationServerName;
443 APRole.Ipv4 = ApplicationServerIP;
444 APRole.Ipv6 = null;
445 APRole.MAC = null;
StringExtensions.cs (https://github.com/ChrisEdwards/Fluency.git) C# · 181 lines
141 public static bool IsValidIpAddress( this string s )
142 {
143 return Regex.IsMatch( s,
144 @"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" );
145 }
164 public static string StripWhitespace( this string value )
165 {
166 return Regex.Replace( value, @"\s", "" );
167 }
DomainSpecParserPassive.cs (https://github.com/ukncsc/mail-check.git) C# · 42 lines
16 //Regex taken from Eddy Minet's .Net implementation http://www.openspf.org/Implementations
17 private readonly Regex _macroRegex = new Regex(@"%{1}\{(?<macro_letter>[slodipvhcrt])(?<digits>[0-9]*)(?<transformer>r)?(?<delimiter>[.+,\/_=-]?)\}", RegexOptions.IgnoreCase);
19 //Credited to bkr : http://stackoverflow.com/questions/11809631/fully-qualified-domain-name-validation
20 private readonly Regex _domainRegex = new Regex(@"(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-_]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}\.?$)");
22 public DomainSpec Parse(string domainSpecString, bool mandatory)
31 }
32 }
33 else if (!_domainRegex.IsMatch(domainSpecString) && !_macroRegex.IsMatch(domainSpecString))
34 {
35 string errorMessage = string.Format(SpfParserResource.InvalidValueErrorMessage, "domain or macro", domainSpecString);
UrlRewriterModule.cs (https://infocontrol.svn.codeplex.com/svn) C# · 160 lines
57 {
58 string lookFor = ResolveUrl(Context.Request.ApplicationPath, rule.From);
59 var reg = new Regex(lookFor, RegexOptions.IgnoreCase);
60 if (reg.IsMatch(requestedUrl))
61 {
150 String strUrl = Context.Request.Url.AbsolutePath;
151 String strDoubleDecodeUrl = Context.Server.UrlDecode(Context.Server.UrlDecode(Context.Request.RawUrl));
152 if (Regex.Match(strUrl, @"[\\/]\.\.[\\/]").Success || Regex.Match(strDoubleDecodeUrl, @"[\\/]\.\.[\\/]").Success)
153 throw new HttpException(404, "Not Found");
EmailValidationRegex.cs (https://github.com/ferventcoder/NuGetGallery.git) C# · 90 lines
12 /// We may add international character support in the function.
13 /// </summary>
14 public class EmailValidationRegex
15 {
16 [Theory]
20 public void TheWholeAllows(string address)
21 {
22 var match = new Regex(RegisterViewModel.EmailValidationRegex).IsMatch(address);
23 Assert.True(match);
24 }
30 public void TheWholeDoesntAllow(string testWhole)
31 {
32 var match = new Regex(RegisterViewModel.EmailValidationRegex).IsMatch(testWhole);
33 Assert.False(match);
34 }
IceParser.cs (https://github.com/RainwayApp/spitfire.git) C# · 204 lines
77 };
79 private static readonly Regex TokenRegex = new Regex("[0-9a-zA-Z\\-\\.!\\%\\*_\\+\\`\\\'\\~]+");
80 private static readonly Regex IceRegex = new Regex("[a-zA-Z0-9\\+\\/]+");
83 private static readonly Regex Ipv4AddressRegex = new Regex("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}");
84 private static readonly Regex Ipv6AdresssRegex = new Regex(":?(?:[0-9a-fA-F]{0,4}:?)+");
86 private static readonly Regex DomainRegex = new Regex(@"(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]");
89 private static readonly Regex ConnectAddressRegex =
90 new Regex($"(?:{Ipv4AddressRegex})|(?:{Ipv6AdresssRegex})|(?:{DomainRegex})");
92 private static readonly Regex PortRegex = new Regex("[0-9]{1,5}");
97 $"({PriorityRegex})\\s({ConnectAddressRegex})\\s({PortRegex})" +
98 $"\\styp\\s({TokenRegex})(?:\\sraddr\\s({ConnectAddressRegex})\\srport\\s({PortRegex}))?(?:\\sgeneration\\s(\\d+))?(?:\\sufrag\\s({IceRegex}))?(?:\\snetwork-id\\s({PriorityRegex}))?(?:\\snetwork-cost\\s({PriorityRegex}))?")
99 ;
100 #endregion
FtpClientHttp11Proxy.cs (https://github.com/AliShahbazi124/FluentFTP.git) C# · 214 lines
140 this.LogLine(FtpTraceLevel.Info, buf);
142 if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success) {
143 reply.Code = m.Groups["code"].Value;
144 reply.Message = m.Groups["message"].Value;
184 this.LogLine(FtpTraceLevel.Info, buf);
186 if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success)
187 {
188 reply.Code = m.Groups["code"].Value;
RuleGroup.cs (https://github.com/pulumi/pulumi-aws.git) C# · 621 lines
88 /// },
89 /// });
90 /// var testRegexPatternSet = new Aws.WafV2.RegexPatternSet("testRegexPatternSet", new Aws.WafV2.RegexPatternSetArgs
91 /// {
92 /// Scope = "REGIONAL",
93 /// RegularExpressions =
94 /// {
95 /// new Aws.WafV2.Inputs.RegexPatternSetRegularExpressionArgs
96 /// {
97 /// RegexString = "one",
305 /// new Aws.WafV2.Inputs.RuleGroupRuleStatementOrStatementStatementArgs
306 /// {
307 /// RegexPatternSetReferenceStatement = new Aws.WafV2.Inputs.RuleGroupRuleStatementOrStatementStatementRegexPatternSetReferenceStatementArgs
308 /// {
309 /// Arn = testRegexPatternSet.Arn,
SwatchesProvider.cs (https://github.com/ButchersBoy/MaterialDesignInXamlToolkit.git) C# · 107 lines
30 var assemblyName = assembly.GetName().Name;
32 var regex = new Regex(@"^themes\/materialdesigncolor\.(?<name>[a-z]+)\.(?<type>primary|accent)\.baml$");
34 Swatches =
35 dictionaryEntries
36 .Select(x => new { key = x.Key.ToString(), match = regex.Match(x.Key.ToString()) })
37 .Where(x => x.match.Success && x.match.Groups["name"].Value != "black")
38 .GroupBy(x => x.match.Groups["name"].Value)
deps.cs (https://github.com/GridProtectionAlliance/go2cs.git) C# · 171 lines
15 using testlog = go.@internal.testlog_package;
16 using io = go.io_package;
17 using regexp = go.regexp_package;
18 using pprof = go.runtime.pprof_package;
19 using strings = go.strings_package;
35 private static @string matchPat = default;
36 private static ptr<regexp.Regexp> matchRe;
38 public static (bool, error) MatchString(this TestDeps _p0, @string pat, @string str)
44 {
45 matchPat = pat;
46 matchRe, err = regexp.Compile(matchPat);
47 if (err != null)
48 {
Solution.cs (https://github.com/dun3/dun3.git) C# · 119 lines
44 public static readonly string GROUPNAME_VERSION = "version";
45 public static readonly Regex PARSE_VERSION_REGEX = new Regex(@"Microsoft Visual Studio Solution File, Format Version (?<" + GROUPNAME_VERSION + ">[0-9\\.]+)", RegexOptions.Compiled | RegexOptions.Multiline);
46 protected virtual void parseVersion(string rawContent)
47 {
48 MatchCollection mc = PARSE_VERSION_REGEX.Matches(rawContent);
49 if (mc.Count == 1)
50 {
62 public static readonly string REGEX_MATCH_GUID = "\\{[a-zA-Z0-9\\-]{36}\\}";
63 //Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "De.Hbv.Framework.Helper", "..\De.Hbv.Framework\Helper\Helper\De.Hbv.Framework.Helper.csproj", "{70EE87C0-4295-4681-97FB-1E9549549B8B}"
64 public static readonly Regex PARSE_SOLUTION_REGEX
65 = new Regex(
69 + "\"(?<" + GROUPNAME_PROJECT_GUID + ">" + REGEX_MATCH_GUID + ")\"",
70 RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline);
71 protected virtual void parseProjectListe(string rawContent)
72 {
Header.cs (http://growl-for-windows.googlecode.com/svn/trunk/) C# · 529 lines
39 /// <summary>
40 /// The RegEx group name for the match that contains the header name (see regExHeader expression below)
41 /// </summary>
42 private const string HEADER_NAME_REGEX_GROUP_NAME = "HeaderName";
44 /// <summary>
45 /// The RegEx group name for the match that contains the header value (see regExHeader expression below)
46 /// </summary>
47 private const string HEADER_VALUE_REGEX_GROUP_NAME = "HeaderValue";
50 /// The regular expression used to parse the header line
51 /// </summary>
52 //private static Regex regExHeader = new Regex(@"(?<HeaderName>[^\r\n:]+):\s+(?<HeaderValue>([\s\S]*\r\n)|(.+))");
53 private static Regex regExHeader = new Regex(@"(?<HeaderName>[^\r\n:]+):\s+(?<HeaderValue>([\s\S]*\Z)|(.+))");
382 if (m.Success)
383 {
384 header = new Header(m.Groups[HEADER_NAME_REGEX_GROUP_NAME].Value.Trim(), m.Groups[HEADER_VALUE_REGEX_GROUP_NAME].Value.Trim());
385 }
386 }
VocabularySubstitutionProcessor.cs (https://texticize.svn.codeplex.com/svn) C# · 174 lines
98 {
99 // Escape begin and end tokens
100 string placeHolderBegin = Regex.Escape(input.Configuration.PlaceHolderBegin);
101 string placeHolderEnd = Regex.Escape(input.Configuration.PlaceHolderEnd);
103 // Generate pattern based on mapy's key and begin and end tokens
104 string originalPattern = placeHolderBegin + Regex.Escape(map.Key) + placeHolderEnd;
106 // Insert parameters pattern into generated pattern
107 string parameterPattern = input.Configuration.TemplateRegexPatternFormatted;
108 string pattern = originalPattern.Insert(originalPattern.Length - placeHolderEnd.Length, parameterPattern);
109 Regex regex = new Regex(pattern, input.Configuration.TemplateRegexOptions);
111 // Get all regex matches in template
112 var matches = regex.Matches(output.Result);
114 // Process each match...
ModuleTests.cs (https://github.com/Hank923/ironruby.git) C# · 277 lines
StringExtensions.cs (https://github.com/PerpetuumOnline/PerpetuumServer.git) C# · 107 lines
13 if (!string.IsNullOrEmpty(attributeName))
14 {
15 return Regex.IsMatch(attributeName, "^attribute[a-zA-Z]$");
16 }
56 {
57 //returns false if an illegal char is found
58 return Regex.IsMatch(source, "^[a-zA-Z0-9_ ]*$");
59 }
96 public static string RemoveSpecialCharacters(this string input)
97 {
98 return Regex.Replace(input,"(?:[^a-z0-9 ]|(?<=['\"])s)",string.Empty, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
99 }
JumonyReader.cs (https://jumony.svn.codeplex.com/svn) C# · 280 lines
20 /// 用于匹配 HTML 标签的正则表达式对象
21 /// </summary>
22 protected static readonly Regex tagRegex = new Regex( tagPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant );
32 if ( !_isWarmedUp )
33 {
34 tagRegex.IsMatch( "" );
35 _isWarmedUp = true;
36 }
138 {
140 Regex endTagRegex = HtmlSpecification.GetEndTagRegex( elementName );
141 var endTagMatch = endTagRegex.Match( HtmlText, index );
161 var match = tagRegex.Match( HtmlText, index );
163 if ( !match.Success )//如果不再有标签的匹配
UserResultController.cs (https://github.com/VashJuan/Dnn.Platform.git) C# · 154 lines
27 private const string LocalizedResxFile = "~/DesktopModules/Admin/SearchResults/App_LocalResources/SearchableModules.resx";
29 private static readonly Regex SearchResultMatchRegex = new Regex(@"^(\d+)_", RegexOptions.Compiled);
31 public override string LocalizedSearchTypeName => Localization.GetString("Crawler_user", LocalizedResxFile);
101 private static int GetUserId(SearchDocumentToDelete searchResult)
102 {
103 var match = SearchResultMatchRegex.Match(searchResult.UniqueKey);
104 return match.Success ? Convert.ToInt32(match.Groups[1].Value) : Null.NullInteger;
105 }
ParameterNameLengthRule.cs (https://git01.codeplex.com/neznayka) C# · 82 lines
60 string typeRegex = @"(?i:^(" + String.Join(@"|", DMVSettings.ExcludedParameterTypesForNameLengthRule) + @")$)";
61 string typename = parameterDeclaration.DataType.Name.Identifiers[0].Value.ToLower();
62 if (!Regex.IsMatch(typename, typeRegex, RegexOptions.None)
63 && parameterDeclaration.Name.Value.Length <= DMVSettings.MinimumParameterNameLength // name includes leading @
64 )
Internet.cs (https://github.com/rscarvalho/FakerSharp.git) C# · 80 lines
9 public class Internet : Base<Internet>
10 {
11 private static Converter<string, string> getInternetName = (str) => new Regex(@"\W").Replace(str, "").ToLower();
13 public static string GetEmail() { return GetEmail(null); }
30 if (name != null)
31 {
32 var parts = from part in new Regex(@"(\w+)").Split(name)
33 where !string.IsNullOrWhiteSpace(part)
34 select part;
66 }
68 public static string IPv6Address
69 {
70 get
DefaultXmlProcessorEngine.cs (https://MB.svn.codeplex.com/svn) C# · 198 lines
Login.cs (https://github.com/1nv4d3r5/Hypermarket-Shop-Management-Tool.git) C# · 216 lines
167 private bool isAlphanumeric(string password)
168 {
169 if (System.Text.RegularExpressions.Regex.IsMatch(password, @"
170 # Match string having one letter and one digit (min).
171 \A # Anchor to start of string.
175 \Z # Anchor to end of string.
176 ",
177 System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace))
178 {
179 return true;
ExportDialog.Designer.cs (https://regexplore.svn.codeplex.com/svn) C# · 159 lines
AbstractHttpData.cs (https://github.com/Azure/DotNetty.git) C# · 137 lines
SqlBuilderBase.cs (https://github.com/dotnetcore/Util.git) C# · 672 lines
ParserPatterns.cs (https://github.com/domialex/Sidekick.git) C# · 205 lines
ConstraintFactory.cs (https://github.com/brentbushnell/pubnub-api.git) C# · 772 lines
696 /// <summary>
697 /// Returns a constraint that succeeds if the actual
698 /// value matches the Regex pattern supplied as an argument.
699 /// </summary>
700 public RegexConstraint Matches(string pattern)
701 {
702 return new RegexConstraint(pattern);
703 }
705 /// <summary>
706 /// Returns a constraint that succeeds if the actual
707 /// value matches the Regex pattern supplied as an argument.
708 /// </summary>
709 public RegexConstraint StringMatching(string pattern)
FXSourceCodeFunction.cs (https://github.com/framefield/tooll.git) C# · 181 lines
NetHelper.cs (https://bitbucket.org/Serg-Norseman/gkcommunicator.git) C# · 93 lines
65 string externalIP = GetPublicAddress().ToString();
66 /*externalIP = (new WebClient()).DownloadString("http://checkip.dyndns.org/");
67 externalIP = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"))
68 .Matches(externalIP)[0].ToString();*/
69 return externalIP;
73 #if NET35
74 // IPv4 192.168.1.1 maps as ::FFFF:192.168.1.1
75 public static IPAddress MapToIPv6(this IPAddress address)
76 {
77 if (address.AddressFamily == AddressFamily.InterNetworkV6) {
IPv4IPv6SubnetmaskOrCIDRValidator.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 33 lines
7 {
8 // ReSharper disable once InconsistentNaming
9 public class IPv4IPv6SubnetmaskOrCIDRValidator : ValidationRule
10 {
11 public override ValidationResult Validate(object value, CultureInfo cultureInfo)
16 var subnetmaskOrCidr = value as string;
18 if (subnetmaskOrCidr != null && Regex.IsMatch(subnetmaskOrCidr, RegexHelper.SubnetmaskRegex))
19 return ValidationResult.ValidResult;
HoconImmutableLiteral.cs (https://github.com/akkadotnet/HOCON.git) C# · 530 lines
458 }
460 private static readonly Regex TimeSpanRegex = new Regex(
461 @"^(?<value>([0-9]+(\.[0-9]+)?))\s*(?<unit>(nanoseconds|nanosecond|nanos|nano|ns|microseconds|microsecond|micros|micro|us|milliseconds|millisecond|millis|milli|ms|seconds|second|s|minutes|minute|m|hours|hour|h|days|day|d))$",
462 RegexOptions.Compiled);
477 return Timeout.InfiniteTimeSpan;
479 var match = TimeSpanRegex.Match(res);
480 if (match.Success)
481 {
HostsDialog.cs (https://github.com/FailedShack/USBHelperLauncher.git) C# · 192 lines
EmailOperationService.cs (https://gitlab.com/rekby-archive/onlyoffice-CommunityServer) C# · 236 lines
89 email = (email ?? "").Trim();
90 if (String.IsNullOrEmpty(email)) throw new ArgumentNullException(Resource.ErrorEmailEmpty);
91 if (!email.TestEmailRegex()) throw new InvalidEmailException(Resource.ErrorNotCorrectEmail);
93 try
172 email = (email ?? "").Trim();
173 if (String.IsNullOrEmpty(email)) throw new Exception(Resource.ErrorEmailEmpty);
174 if (!email.TestEmailRegex()) throw new Exception(Resource.ErrorNotCorrectEmail);
176 try
SIPPacketMangler.cs (https://github.com/sipsorcery/sipsorcery.git) C# · 188 lines
40 {
41 IPAddress addr = SDP.GetSDPRTPEndPoint(sdpBody).Address;
42 //rj2: need to consider publicAddress and IPv6 for mangling
43 IPAddress pubaddr = IPAddress.Parse(publicIPAddress);
44 string sdpAddress = addr.ToString();
49 && addr.AddressFamily == AddressFamily.InterNetworkV6)
50 {
51 string mangledSDP = Regex.Replace(sdpBody, @"c=IN IP6 (?<ipaddress>([:a-fA-F0-9]+))", "c=IN IP6" + publicIPAddress, RegexOptions.Singleline);
52 wasMangled = true;
59 {
60 //logger.LogDebug("MangleSDP replacing private " + sdpAddress + " with " + publicIPAddress + ".");
61 string mangledSDP = Regex.Replace(sdpBody, @"c=IN IP4 (?<ipaddress>(\d+\.){3}\d+)", "c=IN IP4 " + publicIPAddress, RegexOptions.Singleline);
62 wasMangled = true;
Rule.cs (http://zeroflag.googlecode.com/svn/trunk/) C# · 608 lines
330 return a;
331 }
332 public static implicit operator Rule( System.Text.RegularExpressions.Regex regex )
333 {
334 return new RegexTerminal( regex );
365 return a ?? b;
366 }
367 public static Rule operator |( Rule a, System.Text.RegularExpressions.Regex b )
368 {
369 if ( a != null )
387 return a ?? b;
388 }
389 public static Rule operator |( System.Text.RegularExpressions.Regex a, Rule b )
390 {
391 if ( a != null && b != null )
filter.js (http://aipo.googlecode.com/svn/) JavaScript · 70 lines
3 dojo.provide("dojo.data.util.filter");
5 dojo.data.util.filter.patternToRegExp = function(/*String*/pattern, /*boolean?*/ ignoreCase){
6 // summary:
7 // Helper function to convert a simple pattern to a regular expression for matching.
60 rxp += "$";
61 if(ignoreCase){
62 return new RegExp(rxp,"i"); //RegExp
63 }else{
64 return new RegExp(rxp); //RegExp
Rule.cs (https://github.com/stackia/DNSAgent.git) C# · 47 lines
9 {
10 /// <summary>
11 /// Regex pattern to match the domain name.
12 /// </summary>
13 [JsonProperty(Required = Required.Always)]
16 /// <summary>
17 /// IP Address for this domain name. IPv4 address will be returned as A record and IPv6 address as AAAA record.
18 /// </summary>
19 public string Address { get; set; } = null;
SqlClientInstrumentationOptions.cs (https://github.com/open-telemetry/opentelemetry-dotnet.git) C# · 156 lines
36 * [ ] can be any number of white-space, SQL allows it for some reason.
37 */
38 private static readonly Regex DataSourceRegex = new Regex("^(.*?)\\s*(?:[\\\\,]|$)\\s*(.*?)\\s*(?:,|$)\\s*(.*)$", RegexOptions.Compiled);
39 private static readonly ConcurrentDictionary<string, SqlConnectionDetails> ConnectionDetailCache = new ConcurrentDictionary<string, SqlConnectionDetails>(StringComparer.OrdinalIgnoreCase);
59 internal static SqlConnectionDetails ParseDataSource(string dataSource)
60 {
61 Match match = DataSourceRegex.Match(dataSource);
63 string serverHostName = match.Groups[1].Value;
66 var uriHostNameType = Uri.CheckHostName(serverHostName);
67 if (uriHostNameType == UriHostNameType.IPv4 || uriHostNameType == UriHostNameType.IPv6)
68 {
69 serverIpAddress = serverHostName;
UrlParser.cs (https://hg.codeplex.com/century) C# · 191 lines
50 Domain = "localhost";
51 }
52 else if (uri.HostNameType == UriHostNameType.IPv4 || uri.HostNameType == UriHostNameType.IPv6)
53 {
54 Domain = Host;
57 {
58 string subDomainPattern = @"^(?<subdomain>[\w\.\-]+\.)*(?<domain>[\w\-]+\.)(?<com>[\w]{2,3})(?<countryextension>\.[\w]{2})?$";
59 Regex regex = new Regex(subDomainPattern);
60 Match match1 = Regex.Match(uri.Host, subDomainPattern, RegexOptions.RightToLeft);
Network.cs (https://github.com/klemenb/nighthawk.git) C# · 181 lines
126 // convert ipv6 to it's full hexadecimal form
127 public static string IPv6ToFullHex(string ipv6)
128 {
129 return BitConverter.ToString(IPAddress.Parse(ipv6).GetAddressBytes()).Replace("-", "").ToLower();
130 }
132 // check for valid IPv6 /64 prefix
133 public static bool PrefixValid(string prefix)
134 {
135 var regex = new Regex("^([0-9A-Fa-f]{1,4}):([0-9A-Fa-f]{1,4}):([0-9A-Fa-f]{1,4}):([0-9A-Fa-f]{1,4}::)$");
137 return regex.IsMatch(prefix);
138 }
140 // get /64 prefix from IPv6 address
141 public static string GetPrefixFromIP(string ip)
142 {
IPFormatter.cs (https://github.com/HMBSbige/TCPingInfoView.git) C# · 100 lines
9 public static class IPFormatter
10 {
11 public static readonly Regex EndPointRegexStr = new Regex(@"^\[(.*)\]:(\d{1,5})|(.*):(\d{1,5})$");
13 public static bool IsIPAddress(string input)
33 }
35 var sp = EndPointRegexStr.Match(str).Groups;
36 if (sp.Count == 5)
37 {
50 else if (sp.Count == 1)
51 {
52 var groups = Regex.Match(str, @"^\[(.*)\]$").Groups;
53 if (groups.Count == 2)
54 {
AlephTheme.cs (https://github.com/Mikescher/AlephNote.git) C# · 312 lines
80 Tuple.Create("window.inlinesearch.btnWholeWord:background", AlephThemePropType.Brush ),
81 Tuple.Create("window.inlinesearch.btnWholeWord:foreground", AlephThemePropType.Brush ),
82 Tuple.Create("window.inlinesearch.btnRegex:background", AlephThemePropType.Brush ),
83 Tuple.Create("window.inlinesearch.btnRegex:foreground", AlephThemePropType.Brush ),
ConversionCleanUpHandlerTests.cs (https://github.com/sdl/Sdl-Community.git) C# · 972 lines
29 var list = utility.CreateConversionItemLists(searchText: "<.*?>",
30 embeddedTags: true,
31 useRegex: true);
32 var segment = utility.CreateSegment(isLocked: false);
33 var text = utility.CreateText("<html>", segment);
55 var list = utility.CreateConversionItemLists(searchText: "<.*?>",
56 embeddedTags: true,
57 useRegex: true);
58 var segment = utility.CreateSegment(isLocked: false);
59 var text = utility.CreateText("<head>\n<title>\nWhen non - translatable styles were not used\n</title>\n</head>", segment);
101 [Fact]
102 public void VisitSegmentCreatesEmbeddedTagPairRegex()
103 {
104 // Arrange
IPEndPointSerializer.cs (https://github.com/Viagi/LandlordsCore.git) C# · 89 lines
RenameFolderCommandHandler.cs (https://hg.codeplex.com/ruandao) C# · 139 lines
NesMenuCollection.cs (https://github.com/ClusterM/hakchi2.git) C# · 271 lines
LibVlcInteropsManager.cs (https://vlcdotnet.svn.codeplex.com/svn) C# · 170 lines
Comment.cs (https://YABE.svn.codeplex.com/svn) C# · 124 lines
CudaModule.cs (https://github.com/tech-quantum/MxNet.Sharp.git) C# · 81 lines
AboutBox.Designer.cs (https://RegExMaster.svn.codeplex.com/svn) C# · 189 lines
EsqueciMinhaSenha.cs (https://ProjetoFIM.svn.codeplex.com/svn) C# · 120 lines
71 private bool ValidarCampos()
72 {
73 Regex regexEmail = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
75 LN_Usuario objUsuarioLN = new LN_Usuario();
87 return false;
88 }
89 else if (!regexEmail.IsMatch(txtEmail.Text.Trim()))
90 {
91 MessageBox.Show("Informe um e-mail válido.", "Preenchimento obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning);
JumpToKeyDialog.Designer.cs (https://regexplore.svn.codeplex.com/svn) C# · 108 lines
Deobfuscator.cs (https://github.com/brianhama/de4dot.git) C# · 157 lines
26 public const string THE_NAME = "CodeFort";
27 public const string THE_TYPE = "cf";
28 const string DEFAULT_REGEX = @"!^[a-zA-Z]{1,3}$&!^[_<>{}$.`-]$&" + DeobfuscatorBase.DEFAULT_ASIAN_VALID_NAME_REGEX;
29 BoolOption dumpEmbeddedAssemblies;
31 public DeobfuscatorInfo() : base(DEFAULT_REGEX) =>
32 dumpEmbeddedAssemblies = new BoolOption(null, MakeArgName("embedded"), "Dump embedded assemblies", true);
37 public override IDeobfuscator CreateDeobfuscator() =>
38 new Deobfuscator(new Deobfuscator.Options {
39 ValidNameRegex = validNameRegex.Get(),
40 DumpEmbeddedAssemblies = dumpEmbeddedAssemblies.Get(),
41 });
RealestateDomain.cs (https://github.com/riperiperi/FreeSO.git) C# · 129 lines
14 public class RealestateDomain : IRealestateDomain
15 {
16 // No need to check redundant regex conditions until you have to throw various errors
17 // (vide tso.client/UI/Panels/UILotPurchaseDialog.cs)
18 // I tried to combine conditions to reduce redundancy
19 private Regex VALIDATE_SPECIAL_CHARS = new Regex(@"[^\p{L} '-]"); // Numbers are special chars in this case
20 private Regex VALIDATE_APOSTROPHES = new Regex("^[^']*'?[^']*$");
21 private Regex VALIDATE_DASHES = new Regex("^[^-]*-?[^-]*$");
22 private Regex VALIDATE_SPACES = new Regex("^[^ ]+(?: [^ ]+)*$");
PegParser.cs (https://gitlab.com/mirhagk/Pegasus) C# · 97 lines
PackageManagerWindowAnalytics.cs (https://github.com/Unity-Technologies/UnityCsReference.git) C# · 57 lines
34 // remove sensitive part of the id: file path or url is not tracked
35 if (!string.IsNullOrEmpty(packageId))
36 packageId = Regex.Replace(packageId, "(?<package>[^@]+)@(?<protocol>[^:]+):.+", "${package}@${protocol}");
38 var packageFiltering = ServicesContainer.instance.Resolve<PackageFiltering>();
Formats.cs (https://github.com/gregsdennis/Manatee.Json.git) C# · 144 lines
42 /// Gets the `ipv6` format.
43 /// </summary>
44 public static IFormatValidator? Ipv6 => GetFormat(Ipv6FormatValidator.Instance.Format);
45 /// <summary>
46 /// Gets the `iri` format.
58 /// Gets the `regex` format.
59 /// </summary>
60 public static IFormatValidator? Regex => GetFormat(RegexFormatValidator.Instance.Format);
61 /// <summary>
62 /// Gets the `relative-json-pointer` format.
90 [HostNameFormatValidator.Instance.Format] = HostNameFormatValidator.Instance,
91 [Ipv4FormatValidator.Instance.Format] = Ipv4FormatValidator.Instance,
92 [Ipv6FormatValidator.Instance.Format] = Ipv6FormatValidator.Instance,
93 [IriFormatValidator.Instance.Format] = IriFormatValidator.Instance,
94 [IriReferenceFormatValidator.Instance.Format] = IriReferenceFormatValidator.Instance,
IPv4SubnetValidator.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 24 lines
Utility.cs (https://github.com/drittich/DnsTube.git) C# · 85 lines
15 var attempts = 0;
16 errorMesssage = null;
17 var url = protocol == IpSupport.IPv4 ? "http://ipv4bot.whatismyipaddress.com" : "http://ipv6bot.whatismyipaddress.com";
19 while (publicIpAddress == null && attempts < maxAttempts)
77 else
78 {
79 var regex = new Regex(@"(?:^|(?<=\s))(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(?=\s|$)");
80 var match = regex.Match(ipString);
frmMain.cs (https://BusTravel.svn.codeplex.com/svn) C# · 233 lines
Value.cs (https://github.com/EPPlusSoftware/EPPlus.git) C# · 95 lines
67 }
68 }
69 if (Regex.IsMatch(val, $"^[\\d]*({Regex.Escape(_groupSeparator)}?[\\d]*)?({Regex.Escape(_decimalSeparator)}[\\d]*)*?[ ?% ?]?$", RegexOptions.Compiled))
70 {
71 result = double.Parse(val, _cultureInfo);
78 var timeSeparator = Regex.Escape(_timeSeparator);
79 if (Regex.IsMatch(val, @"^[\d]{1,2}" + timeSeparator + @"[\d]{2}(" + timeSeparator + @"[\d]{2})?$", RegexOptions.Compiled))
80 {
81 var timeResult = _timeValueFunc.Execute(val);
WindowProperties.cs (https://hawkeye.svn.codeplex.com/svn) C# · 160 lines
ReplaceForm.Designer.cs (https://github.com/pascalabcnet/pascalabcnet.git) C# · 241 lines
34 this.btCancel = new System.Windows.Forms.Button();
35 this.groupBox1 = new System.Windows.Forms.GroupBox();
36 this.cbUseRegex = new System.Windows.Forms.CheckBox();
37 this.cbSearchUp = new System.Windows.Forms.CheckBox();
38 this.cbMathWord = new System.Windows.Forms.CheckBox();
90 // groupBox1
91 //
92 this.groupBox1.Controls.Add(this.cbUseRegex);
93 this.groupBox1.Controls.Add(this.cbSearchUp);
94 this.groupBox1.Controls.Add(this.cbMathWord);
109 this.cbUseRegex.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
110 this.cbUseRegex.Name = "cbUseRegex";
111 this.cbUseRegex.Size = new System.Drawing.Size(111, 21);
112 this.cbUseRegex.TabIndex = 3;
113 this.cbUseRegex.Text = "USE_REGEX";
114 this.cbUseRegex.UseVisualStyleBackColor = true;
QuantifierNode.cs (https://github.com/Jcparkyn/nodexr.git) C# · 150 lines
9 namespace Nodexr.NodeTypes
10 {
11 public class QuantifierNode : RegexNodeViewModelBase, IQuantifiableNode
12 {
13 public override string Title => "Quantifier";
16 "of 'repeats' for the inputted node. Leave the 'max' option blank to allow unlimited repeats." +
17 "\n'Greedy' and 'Lazy' search type will attempt to match as many or as few times as possible respectively." +
18 "\nThe .NET Regex engine does not support possessive quantifiers, so they are automatically replaced " +
19 "by atomic groups (which are functionally identical).";
50 {
51 Title = "Search type:",
52 Description = "Changes the way that the Regex engine tries to match the repetition."
53 };
ParserTests.cs (https://github.com/sebastienros/esprima-dotnet.git) C# · 191 lines
PoshLTM.Types.cs (https://github.com/joel74/POSH-LTM-Rest.git) C# · 145 lines
17 string hostname = address;
18 // Extract a RouteDomain, if applicable
19 if (Regex.IsMatch(address,"%[0-9]+$"))
20 {
21 hostname = address.Split('%')[0];
23 }
24 // IPv4 Addresses always start with a number, server names can not
25 if (Regex.IsMatch(hostname,"^[0-9]"))
26 {
27 IPAddress = IPAddress.Parse(hostname);
34 {
35 // Resolve hostname
36 // IPv6 Addresses do not always start with a number, but resolve nicely
37 foreach (IPAddress IPA in Dns.GetHostAddresses(hostname))
38 {
XMLDataSet.cs (https://hg.codeplex.com/posttracker) C# · 175 lines
ImageLocalSaverTests.cs (https://github.com/chenzhongfang/MindMate.git) C# · 328 lines
45 Assert.IsTrue(html.Contains("srcOrig"));
46 int imgUpdated = Regex.Matches(html, "srcOrig", RegexOptions.IgnoreCase).Count;
47 Assert.AreEqual(79, imgUpdated);
49 int imgCount = Regex.Matches(html, "<img", RegexOptions.IgnoreCase).Count;
50 Assert.IsTrue(imgCount > imgUpdated);
51 }
80 Assert.IsTrue(html.Contains("srcOrig"));
81 int imgUpdated = Regex.Matches(html, "srcOrig", RegexOptions.IgnoreCase).Count;
82 Assert.AreEqual(79, imgUpdated);
ChangePassword.cs (https://github.com/1nv4d3r5/Hypermarket-Shop-Management-Tool.git) C# · 116 lines
74 private bool isAlphanumeric(string password)
75 {
76 if (System.Text.RegularExpressions.Regex.IsMatch(password, @"
77 # Match string having one letter and one digit (min).
78 \A # Anchor to start of string.
82 \Z # Anchor to end of string.
83 ",
84 System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace))
85 {
86 return true;
currency.js (http://aipo.googlecode.com/svn/) JavaScript · 104 lines
StringFormatWith.cs (https://github.com/ParticularLabs/GitVersion.git) C# · 77 lines
6 internal static class StringFormatWithExtension
7 {
8 // This regex matches an expression to replace.
9 // - env:ENV name OR a member name
10 // - optional fallback value after " ?? "
11 // - the fallback value should be a quoted string, but simple unquoted text is allowed for back compat
12 private static readonly Regex TokensRegex = new(@"{((env:(?<envvar>\w+))|(?<member>\w+))(\s+(\?\?)??\s+((?<fallback>\w+)|""(?<fallback>.*)""))??}", RegexOptions.Compiled);
14 /// <summary>
41 }
43 foreach (Match match in TokensRegex.Matches(template))
44 {
45 string propertyValue;
IPEndPointSerializer.cs (https://github.com/tmcgannon/mongo-csharp-driver.git) C# · 132 lines
75 case BsonType.String:
76 var stringValue = bsonReader.ReadString();
77 var match = Regex.Match(stringValue, @"^(?<address>(.+|\[.*\]))\:(?<port>\d+)$");
78 if (match.Success)
79 {
123 else
124 {
125 stringValue = string.Format("[{0}]:{1}", endPoint.Address, endPoint.Port); // IPv6
126 }
127 bsonWriter.WriteString(stringValue);
LanguageParser.cs (https://github.com/ABTSoftware/SciChart.WPF.Examples.git) C# · 204 lines
125 for (int i = 0; i < regexMatch.Groups.Count; i++)
126 {
127 Group regexGroup = regexMatch.Groups[i];
128 string styleName = compiledLanguage.Captures[i];
131 continue;
132 else
133 foreach (Capture regexCapture in regexGroup.Captures)
134 AppendCapturedStylesForRegexCapture(regexCapture, currentIndex, styleName, capturedStyles);
165 CompiledLanguage nestedCompiledLanguage = languageCompiler.Compile(nestedLanguage);
167 Match regexMatch = nestedCompiledLanguage.Regex.Match(regexCapture.Value, 0, regexCapture.Value.Length);
169 if (!regexMatch.Success)
182 }
184 regexMatch = regexMatch.NextMatch();
185 }
186 }
ipendpoint.cs (https://github.com/dotnet/dotnet-api-docs.git) C# · 254 lines
137 // Note that in the for loop a temporary socket is created to ensure that
138 // the current IP address format matches the AddressFamily type.
139 // In fact, in the case of servers supporting both IPv4 and IPv6, an exception
140 // may arise if an IP address format does not match the address family type.
141 private static SocketAddress getSocketAddress(string server, int port)
228 // This is a security check. It allows only
229 // alphanumeric input string between 2 to 40 character long.
230 Regex rex = new Regex(@"^[a-zA-Z]\w{1,39}$");
232 if (args.Length < 1)
MyTextBox.xaml.cs (https://gitlab.com/prog76.own/SoftGetaway) C# · 131 lines
20 /// </summary>
21 public partial class MyTextBox : UserControl, INotifyPropertyChanged {
22 Regex rex;
23 bool fIsValid;
25 public MyTextBox() {
26 InitializeComponent();
27 rex = new Regex(".*");
28 maskedBox.TextChanged += new TextChangedEventHandler(maskedBox_TextChanged);
29 DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(TextBox.IsEnabledProperty, typeof(TextBox));
67 public String Mask {
68 get { return rex.ToString(); }
69 set { rex = new Regex(value); }
70 }
71 public String ErrorMessage {
AboutForm.Designer.cs (https://dotnetregex.svn.codeplex.com/svn) C# · 124 lines
HostNameResolver.cs (https://secureftp.svn.codeplex.com/svn) C# · 60 lines
34 public class HostNameResolver
35 {
36 private const string IP_ADDRESS_REGEX = @"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}";
38 public static IPAddress GetAddress(string hostName)
41 throw new ArgumentNullException();
42 IPAddress address = null;
43 if (Regex.IsMatch(hostName, IP_ADDRESS_REGEX))
44 address = IPAddress.Parse(hostName);
45 else
50 if (a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
51 address = a;
52 // otherwise throw an exception coz we don't handle IPv6 yet.
53 if (address == null)
54 throw new ArgumentException(hostName + " resolves to an unsupported protocol.");
Builder.pm
(https://swig.svn.sourceforge.net/svnroot/swig)
Perl · 1592 lines
✨ Summary
This is a Perl module that provides a builder for writing tests. It allows developers to create test cases with a simple syntax and automatically reports the number of passed, failed, and skipped tests. The module also handles edge cases such as missing or extra tests, and provides exit codes indicating the outcome of the test run.
This is a Perl module that provides a builder for writing tests. It allows developers to create test cases with a simple syntax and automatically reports the number of passed, failed, and skipped tests. The module also handles edge cases such as missing or extra tests, and provides exit codes indicating the outcome of the test run.
611 =item B<maybe_regex>
613 $Test->maybe_regex(qr/$regex/);
614 $Test->maybe_regex('/$regex/');
629 my ($self, $this, $regex, $name) = @_;
630 my $usable_regex = $self->maybe_regex($regex);
631 die "expecting regex, found '$regex'\n"
667 my $ok = 0;
668 my $usable_regex = $self->maybe_regex($regex);
669 unless (defined $usable_regex) {
670 $ok = $self->ok( 0, $name );
671 $self->diag(" '$regex' doesn't look much like a regex to me.");
672 return $ok;
673 }
InputBox.cs (https://github.com/Orbmu2k/nvidiaProfileInspector.git) C# · 92 lines
9 internal class InputBox
10 {
11 internal static DialogResult Show(string title, string promptText, ref string value, List<string> invalidInputs, string mandatoryFormatRegExPattern, int maxLength)
12 {
13 var form = new Form();
20 EventHandler textchanged = delegate (object sender, EventArgs e)
21 {
22 bool mandatory_success = Regex.IsMatch(textBox.Text, mandatoryFormatRegExPattern);
24 if (textBox.Text == "" || textBox.Text.Length > maxLength || !mandatory_success)
MSServicesCommandRegistrar.cs (https://msservices.svn.codeplex.com/svn) C# · 630 lines
98 AddMoveUpDownCommands(typeof(MinMaxValidatorNode));
99 AddMoveUpDownCommands(typeof(ListValidatorNode));
100 AddMoveUpDownCommands(typeof(RegExpValidatorNode));
101 AddMoveUpDownCommands(typeof(DatabaseValidatorNode));
102 AddMoveUpDownCommands(typeof(SQLValidatorNode));
105 AddDefaultCommands(typeof(MinMaxValidatorNode));
106 AddDefaultCommands(typeof(ListValidatorNode));
107 AddDefaultCommands(typeof(RegExpValidatorNode));
108 AddDefaultCommands(typeof(DatabaseValidatorNode));
109 AddDefaultCommands(typeof(SQLValidatorNode));
530 typeof(ListValidatorNode),
531 typeof(ParameterNode));
532 AddSingleChildNodeCommand(Resources.RegExpValidatorCommandText,
533 string.Format(Resources.GenericCommandLongText, Resources.RegExpValidatorCommandText),
534 typeof(RegExpValidatorNode),
535 typeof(ParameterNode));
536 AddMultipleChildNodeCommand(Resources.DatabaseValidatorCommandText,
Settings.cs (https://github.com/lastbattle/Harepacker-resurrected.git) C# · 185 lines
74 theSettings= Regex.Replace(theSettings, @"(?<=!DPt:)-?\d*(?=!)", PrevTBox.Text);
75 /*theSettings = theSettings.Remove(Regex.Match(theSettings, @"(?<=!DPt:)-?\d*(?=!)").Index, Regex.Match(theSettings, @"(?<=!DPt:)-?\d*(?=!)").Length);// Regex: One or zero -, Any number of digits with the prefix !DPt: and suffix !
76 theSettings = theSettings.Insert(Regex.Match(theSettings, @"(?<=!DPt:)!").Index, PrevTBox.Text);*/
77 theSettings = Regex.Replace(theSettings, @"(?<=!DPc:)\w+(?=!)", PrevCBox.Checked.ToString());
78 /* theSettings = theSettings.Remove(Regex.Match(theSettings, @"(?<=!DPc:)\w+(?=!)").Index, Regex.Match(theSettings, @"(?<=!DPc:)\w+(?=!)").Length);// Regex: One or more number of alphanumeric chars with the prefix !DPc: and suffix !
79 theSettings = theSettings.Insert(Regex.Match(theSettings, @"(?<=!DPc:)!").Index, PrevCBox.Checked.ToString());*/
80 theSettings = Regex.Replace(theSettings, @"(?<=!DNt:)-?\d*(?=!)", NextTBox.Text);
81 /*theSettings = theSettings.Remove(Regex.Match(theSettings, @"(?<=!DNt:)-?\d*(?=!)").Index, Regex.Match(theSettings, @"(?<=!DNt:)-?\d*(?=!)").Length);
82 theSettings = theSettings.Insert(Regex.Match(theSettings, @"(?<=!DNt:)!").Index, NextTBox.Text);*/
104 theSettings = Regex.Replace(theSettings, @"(?<=!DTt:)-?\d*(?=!)", TypeTBox.Text);
105 /*theSettings = theSettings.Remove(Regex.Match(theSettings, @"(?<=!DTt:)\d*(?=!)").Index, Regex.Match(theSettings, @"(?<=!DTt:)\d*(?=!)").Length);
106 theSettings = theSettings.Insert(Regex.Match(theSettings, @"(?<=!DTt:)!").Index, TypeTBox.Text);*/
113 theSettings = Regex.Replace(theSettings, @"(?<=!DFPc:)\w+(?=!)", FilepathCBox.Checked.ToString());
114 /* theSettings = theSettings.Remove(Regex.Match(theSettings, @"(?<=!DFPc:)\w+(?=!)").Index, Regex.Match(theSettings, @"(?<=!DFPc:)\w+(?=!)").Length);
115 theSettings = theSettings.Insert(Regex.Match(theSettings, @"(?<=!DFPc:)!").Index, FilepathCBox.Checked.ToString());*/
DataViewModel.cs (https://github.com/huangjia2107/XamlViewer.git) C# · 244 lines
CustomComparers.cs (https://github.com/R-Smith/tcpTrigger.git) C# · 63 lines
8 {
9 // Sort list of IP addresses so that IPv4 addresses appear sorted first
10 // followed by sorted IPv6 addresses.
11 public int Compare(IPAddress a, IPAddress b)
12 {
48 return 1;
50 Regex regex = new Regex("^(\\d+)");
51 Match xMatch = regex.Match(x);
52 Match yMatch = regex.Match(y);
54 if (xMatch.Success && yMatch.Success)
NameHelpers.cs (https://github.com/jskeet/protobuf-csharp-port.git) C# · 140 lines
48 /// All characters that are not alpha-numeric
49 /// </summary>
50 private static readonly Regex NonAlphaNumericCharacters = new Regex(@"[^a-zA-Z0-9]+");
52 /// <summary>
53 /// Matches lower-case character that follow either an underscore, or a number
54 /// </summary>
55 private static readonly Regex UnderscoreOrNumberWithLowerCase = new Regex(@"[0-9_][a-z]");
57 /// <summary>
ConsoleIO.cs (https://github.com/caphindsight/TrulyQuantumChess.git) C# · 180 lines
23 string move_str = Console.ReadLine();
25 string capitulate_move_regex = @"^(quit|exit|capitulate)$";
26 string agree_to_tie_move_regex = @"^tie$";
29 string castle_move_regex = @"^castle (left|right)$";
31 Match ordinary_match = Regex.Match(move_str, ordinary_move_regex);
32 Match quantum_match = Regex.Match(move_str, quantum_move_regex);
33 Match castle_match = Regex.Match(move_str, castle_move_regex);
35 if (Regex.IsMatch(move_str, capitulate_move_regex)) {
36 return new CapitulateMove(engine.ActivePlayer);
37 } else if (Regex.IsMatch(move_str, agree_to_tie_move_regex)) {
38 return new AgreeToTieMove(engine.ActivePlayer);
39 } else if (ordinary_match.Success) {
System.cs (https://github.com/mrellipse/toucan.git) C# · 128 lines
48 private static TimeSpan GetSpecifiedOffset(string value)
49 {
50 var match = Regex.Match(value, @"(?:GMT)([\d\+|-]{5})").ToString().Replace("GMT", "");
52 bool positive = match.StartsWith("+");
67 private static DateTime? StrategyGMT(string value, CultureInfo culture, TimeZoneInfo sourceTimeZone)
68 {
69 if (Regex.IsMatch(value, @"(GMT\+[\d]+\s\([\w\s]+\))+")) // Javascript = new Date().toString()
70 {
71 var values = value.Split(" ").ToArray();
StringUtils.cs (git://github.com/ccollie/Guanima.Redis.git) C# · 51 lines
6 public class StringUtils
7 {
8 const string IPRegexPattern = @"
9 ^( # Anchor to the beginning of the line
10 # Invalidations
15 (\d{1,3}) # Between 1-3 numbers
16 (?:[.-]?) # Match but don't capture a . or -
17 ){4,6} # IPV4 IPV6
18 (?<Url>[A-Za-z.\d]*?) # Subdomain is mostly text
19 (?::)
20 (?<Port>\d+)";
22 private static readonly Regex IPRegex = new Regex(IPRegexPattern,
23 RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
27 if (!String.IsNullOrEmpty(candidate))
28 {
29 Match m = IPRegex.Match(candidate);
30 if (m.Success)
31 {
ValidationErrorKind.cs (https://github.com/RSuter/NJsonSchema.git) C# · 146 lines
NewsViewModel.cs (https://github.com/NikolayIT/PressCenters.com.git) C# · 136 lines
130 strippedContent = strippedContent.Replace("\n", " ");
131 strippedContent = strippedContent.Replace("\t", " ");
132 strippedContent = Regex.Replace(strippedContent, @"\s+", " ").Trim();
133 return strippedContent.Length <= maxLength ? strippedContent : strippedContent.Substring(0, maxLength) + "...";
134 }
NormalizedRequest.cs (https://github.com/hanimourra/Thinktecture.IdentityModel.45.git) C# · 136 lines
31 private const string HTTPS_PORT = "443";
32 private const string MATCH_PATTERN_HOSTNAME_OR_IPV4 = @"^(?:(?:\r\n)?\s)*([^:]+)(?::(\d+))?(?:(?:\r\n)?\s)*$";
33 private const string MATCH_PATTERN_IPV6 = @"^(?:(?:\r\n)?\s)*(\[[^\]]+\])(?::(\d+))?(?:(?:\r\n)?\s)*$";
34 private const string XFF_HEADER_NAME = "X-Forwarded-For";
103 if (!String.IsNullOrWhiteSpace(hostHeader))
104 {
105 string pattern = hostHeader[0] == '[' ? MATCH_PATTERN_IPV6 : MATCH_PATTERN_HOSTNAME_OR_IPV4;
106 var match = Regex.Match(hostHeader, pattern);