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";

22

23 private static readonly Regex VARIABLE = new Regex(@"\{(\w+)\}");

24

25 private static char[] ARGUMENT_SEPARATORS = new char[] { ' ', '\t' };

75

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);

129

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);

175

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);

177

178 internal static bool IsValidHost(this string value)

187 return true;

188

189 if (_reIPv6.Match(value).Success)

190 return true;

191

RegexMatchTests4.cs (https://github.com/EricWhiteDev/corefx.git) C# · 345 lines

7 using Xunit;

8

9 public partial class RegexMatchTests

10 {

11 /*

31

32 [Fact]

33 public static void RegexMatchTestCase4()

34 {

35 //////////// Global Variables used for all tests

38 int iCountErrors = 0;

39 int iCountTestcases = 0;

40 Regex r;

41 Match match;

42 String strMatch1 = "aaabbbccc";

NetworkAddressChange.OSX.cs (https://gitlab.com/0072016/0072016-corefx-) C# · 188 lines

22 private static NetworkAddressChangedEventHandler s_addressChangedSubscribers;

23

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 }

166

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.

25 //{{{ Imports

26 import java.util.*;

27 import java.util.regex.*;

28 import org.gjt.sp.jedit.*;

29 import org.gjt.sp.jedit.buffer.JEditBuffer;

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 }

87

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*)%");

22

23 public DismImageService(IFileSystemOperations fileSystemOperations) : base(fileSystemOperations)

96 }

97

98 var matches = percentRegex.Match(dismOutput);

99

100 if (matches.Success)

LargeFileTest.cs (https://github.com/Microsoft/BuildXL.git) C# · 117 lines

57 {name: 'TMP', value: []},

58 ],

59 warningRegex: '^\\s*((((((\\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)|())(()|([^:]*? ))warning( \\s*([^: ]*))?\\s*:.*$',

60 acquireSemaphores: [

61 {

IIPAddress.cs (https://github.com/Vanaheimr/Hermod.git) C# · 160 lines

32

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");

35

36 //ToDo: Better do this by hand!

37 public static Regex IPv6AddressRegExpr = new Regex(@"(([a-f0-9:]+:+)+[a-f0-9]+)");

38

39

88 public static Boolean IsIPv6(String IPAddress)

89 => IPAddress.IsNotNullOrEmpty() &&

90 IPv6AddressRegExpr.IsMatch(IPAddress?.Trim());

91

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

84 else if (error_number == JSError.PrecisionOutOfRange)

85 return "The number of fractional digits is out of range";

86 else if (error_number == JSError.RegExpSyntax)

87 return "Syntax error in regular expression";

88 else if (error_number == JSError.TypeMismatch)

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

103 paste-previous.shortcut=C+e C+v

104 close-all.shortcut=C+e C+w

105 regexp.shortcut=C+e C+x

106 paste-deleted.shortcut=C+e C+y

107 redo.shortcut=C+e C+z

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.

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 }

84

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

95 {

96 var title = itemNode.InnerXml.Substring(0, itemNode.InnerXml.IndexOf('<'));

97 var year = Regex.Match(itemNode.InnerXml, @"\d\d\d\d");

98 resultList.Add(string.Format("{0} ({1})", title, year));

99 }

FtpClientHttp11Proxy.cs (https://github.com/robinrodricks/FluentFTP.git) C# · 210 lines

141 LogLine(FtpTraceLevel.Info, buf);

142

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);

184

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;

24

25 // 192.168.0.0/24

26 if (Regex.IsMatch(ipHostOrRange, RegexHelper.IPv4AddressCidrRegex))

27 continue;

28

70

71 // 2001:db8:85a3::8a2e:370:7334

72 if (Regex.IsMatch(ipHostOrRange, RegexHelper.IPv6AddressRegex))

73 continue;

74

HostRangeHelper.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 218 lines

38

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);

127

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

18 // Don't break on colons (:) as they are used in IPv6 addresses

19 Regex splitter = new Regex(@"^-{1,2}|^/|=",RegexOptions.IgnoreCase|RegexOptions.Compiled);

20 Regex remover = new Regex(@"^['""]?(.*?)['""]?$",RegexOptions.IgnoreCase|RegexOptions.Compiled);

cHelper.cs (https://dbcopytool.svn.codeplex.com/svn) C# · 103 lines

24

25

26 public static bool CheckFilePathRegex(string sFilepath)

27 {

28 //check if dirs are dirs

29 Regex reFoldername = new Regex("^[A-Za-z]:\\\\(.)*(\\\\)*$");

30

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).

100

101 foreach (IPAddress address in hostEntry.AddressList)

245

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

209

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.

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;

139

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;

249

Template.cs (https://bitbucket.org/jdeselms/magenoco.git) C# · 155 lines

22 private readonly Template _fileNameTemplateOrNull;

23

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

1 namespace CrackSoft.RegExplore

2 {

3 partial class AboutBox

ImageFlasher.cs (https://github.com/WOA-Project/WOA-Deployer.git) C# · 106 lines

17 public class ImageFlasher : IImageFlasher

18 {

19 private readonly Regex percentRegex = new Regex(@"(\d*.\d*)%");

20

21 public string EtcherPath

85 }

86

87 var matches = percentRegex.Match(output);

88

89 if (matches.Success)

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);

20

21 private ITexture _Texture = null;

208 this._FrameSizePixels = this.Texture.Size;

209

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 }

56

57 private static Regex _iniKeyValuePatternRegex;

58

59 public IniFile(string iniFileName)

ConstraintBuilder.cs (https://github.com/letssellsomebananas/mono.git) C# · 436 lines

254 public Constraint Matches(string pattern)

255 {

256 return Resolve(new RegexConstraint(pattern));

257 }

258 #endregion

UriPatternService.cs (http://exyus.googlecode.com/svn/trunk/) C# · 185 lines

153 {

154 string pattern = Enumerator.Key.ToString();

155 //relativeUrl = Regex.Replace(relativeUrl, @"/([^.?]*)(?:\.xcs)?(\?.*)?", "/$1$2", RegexOptions.IgnoreCase);

156 if (new Regex(pattern, RegexOptions.IgnoreCase).IsMatch(relativeUrl))

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.

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})$");

158

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,})$");

177

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();

21

22

121 {

122

123 Regex endTagRegex = HtmlSpecification.GetEndTagRegex( elementName );

124 var endTagMatch = endTagRegex.Match( HtmlText, index );

142

143

144 var match = tagRegex.Match( HtmlText, index );

145

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.

1 /*

2 * gnu/regexp/CharIndexed.java

3 * Copyright (C) 1998-2001 Wes Biggs

4 *

17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

18 */

19 package gnu.regexp;

20

21 /**

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);

41

42 if (string.Equals(componentCandidate.ItemSpec, razorComponent, StringComparison.OrdinalIgnoreCase))

InternetTest.cs (https://github.com/rscarvalho/FakerSharp.git) C# · 206 lines

190 string actual;

191 actual = Internet.IPv4Address;

192 Assert.IsTrue(new Regex(@"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$").IsMatch(actual));

193 }

194

195 /// <summary>

196 ///A test for IPv6Address

197 ///</summary>

198 [TestMethod()]

199 public void IPv6AddressTest()

200 {

201 string actual;

NetworkBaseCmdlet.cs (https://github.com/Azure/azure-powershell.git) C# · 130 lines

27

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

4 /// 包含一些正则验证所需要的字符串

5 /// </summary>

6 public sealed class RegexPatterns

7 {

8 /// <summary>

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;

439

442 APRole.ComputerName = ApplicationServerName;

443 APRole.Ipv4 = ApplicationServerIP;

444 APRole.Ipv6 = null;

445 APRole.MAC = null;

446

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 }

168

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);

18

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}\.?$)");

21

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");

154

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 };

78

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}:?)+");

85

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})");

91

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);

141

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);

185

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;

31

32 var regex = new Regex(@"^themes\/materialdesigncolor\.(?<name>[a-z]+)\.(?<type>primary|accent)\.baml$");

33

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;

34

35 private static @string matchPat = default;

36 private static ptr<regexp.Regexp> matchRe;

37

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

43

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

38

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";

43

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);

102

103 // Generate pattern based on mapy's key and begin and end tokens

104 string originalPattern = placeHolderBegin + Regex.Escape(map.Key) + placeHolderEnd;

105

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);

110

111 // Get all regex matches in template

112 var matches = regex.Matches(output.Result);

113

114 // Process each match...

ModuleTests.cs (https://github.com/Hank923/ironruby.git) C# · 277 lines

124 p Hash.dup.new('default')[1]

125 p Range.dup.new(1,2)

126 p Regexp.dup.new('foo')

127 p Module.dup.new.name

128 p Struct.dup.new(:a,:b).dup[1,2].dup.members

137 class H < Hash; end

138 class R < Range; end

139 class RE < Regexp; end

140 class M < Module; end

141 class St < Struct; end

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 }

17

56 {

57 //returns false if an illegal char is found

58 return Regex.IsMatch(source, "^[a-zA-Z0-9_ ]*$");

59 }

60

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 }

100

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 );

23

24

32 if ( !_isWarmedUp )

33 {

34 tagRegex.IsMatch( "" );

35 _isWarmedUp = true;

36 }

138 {

139

140 Regex endTagRegex = HtmlSpecification.GetEndTagRegex( elementName );

141 var endTagMatch = endTagRegex.Match( HtmlText, index );

159

160

161 var match = tagRegex.Match( HtmlText, index );

162

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";

28

29 private static readonly Regex SearchResultMatchRegex = new Regex(@"^(\d+)_", RegexOptions.Compiled);

30

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();

12

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 }

67

68 public static string IPv6Address

69 {

70 get

DefaultXmlProcessorEngine.cs (https://MB.svn.codeplex.com/svn) C# · 198 lines

11 class DefaultXmlProcessorEngine : IXmlProcessorEngine

12 {

13 private readonly Regex flagPattern = new Regex(@"^(\w|_)+$");

14 private readonly IDictionary properties = new HybridDictionary();

15 private readonly IDictionary flags = new HybridDictionary();

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

1 namespace CrackSoft.RegExplore

2 {

3 partial class ExportDialog

AbstractHttpData.cs (https://github.com/Azure/DotNetty.git) C# · 137 lines

18 public abstract class AbstractHttpData : AbstractReferenceCounted, IHttpData

19 {

20 static readonly Regex StripPattern = new Regex("(?:^\\s+|\\s+$|\\n)", RegexOptions.Compiled);

21 static readonly Regex ReplacePattern = new Regex("[\\r\\t]", RegexOptions.Compiled);

SqlBuilderBase.cs (https://github.com/dotnetcore/Util.git) C# · 672 lines

396 var parameters = GetParams();

397 foreach( var parameter in parameters )

398 sql = Regex.Replace( sql, $@"{parameter.Key}\b", ParamLiteralsResolver.GetParamLiterals( parameter.Value ) );

399 return sql;

400 }

ParserPatterns.cs (https://github.com/domialex/Sidekick.git) C# · 205 lines

136 #region Helpers

137

138 public int GetInt(Regex regex, string input)

139 {

140 if (regex != null)

154 }

155

156 public double GetDouble(Regex regex, string input)

157 {

158 if (regex != null)

172 }

173

174 public double GetDps(Regex regex, string input, double attacksPerSecond)

175 {

176 if (regex != null)

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 }

704

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

79 {

80 var errors = new CompilerErrorCollection();

81 var errorLinePattern = new Regex(@"\((\d+),(\d+)\): error\s*(\w+):\s*(.*?)\s*$");

82

83 foreach (var line in errorString.Split('\n'))

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;

17

18 if (subnetmaskOrCidr != null && Regex.IsMatch(subnetmaskOrCidr, RegexHelper.SubnetmaskRegex))

19 return ValidationResult.ValidResult;

20

HoconImmutableLiteral.cs (https://github.com/akkadotnet/HOCON.git) C# · 530 lines

458 }

459

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;

478

479 var match = TimeSpanRegex.Match(res);

480 if (match.Success)

481 {

HostsDialog.cs (https://github.com/FailedShack/USBHelperLauncher.git) C# · 192 lines

50 {

51 case 0:

52 if (value == string.Empty || Regex.IsMatch(value, @"\s"))

53 {

54 e.Cancel = true;

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);

92

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);

175

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;

53

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;

63

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");

4

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)]

15

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);

40

59 internal static SqlConnectionDetails ParseDataSource(string dataSource)

60 {

61 Match match = DataSourceRegex.Match(dataSource);

62

63 string serverHostName = match.Groups[1].Value;

65

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 }

131

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}::)$");

136

137 return regex.IsMatch(prefix);

138 }

139

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})$");

12

13 public static bool IsIPAddress(string input)

33 }

34

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);

100

101 [Fact]

102 public void VisitSegmentCreatesEmbeddedTagPairRegex()

103 {

104 // Arrange

IPEndPointSerializer.cs (https://github.com/Viagi/LandlordsCore.git) C# · 89 lines

47

48 var stringValue = bsonReader.ReadString();

49 var match = Regex.Match(stringValue, @"^(?<address>(.+|\[.*\]))\:(?<port>\d+)$");

50 if (match.Success)

51 {

82 else

83 {

84 stringValue = string.Format("[{0}]:{1}", value.Address, value.Port); // IPv6

85 }

86 bsonWriter.WriteString(stringValue);

RenameFolderCommandHandler.cs (https://hg.codeplex.com/ruandao) C# · 139 lines

126 catch { /* No errors if we are not able to delete the thumb. */ }

127

128 string newFolderPath = Regex.Replace( this.CurrentFolder.ClientPath, "[^/]+/?$", newFileName ) + "/";

129 string newFolderUrl = this.CurrentFolder.ResourceTypeInfo.Url + newFolderPath.TrimStart( '/' );

130

NesMenuCollection.cs (https://github.com/ClusterM/hakchi2.git) C# · 271 lines

54 var partsCount = (int)Math.Ceiling((float)total / (float)maxElements);

55 var perPart = (int)Math.Ceiling((float)total / (float)partsCount);

56 var alphaNum = new Regex("[^a-zA-Z0-9]");

57

58 NesMenuCollection root;

LibVlcInteropsManager.cs (https://vlcdotnet.svn.codeplex.com/svn) C# · 170 lines

140 GetVersion = new LibVlcFunction<GetVersion>(myLibVlcDllHandle);

141

142 var reg = new Regex("^[0-9.]*");

143 var match = reg.Match(IntPtrExtensions.ToStringAnsi(GetVersion.Invoke()));

144 VlcVersion = new Version(match.Groups[0].Value);

Comment.cs (https://YABE.svn.codeplex.com/svn) C# · 124 lines

69 return EmailValidation;

70 }

71 string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +

72 @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +

73 @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

74 Regex regex = new Regex(strRegex);

75 if(!regex.IsMatch(this.Email))

CudaModule.cs (https://github.com/tech-quantum/MxNet.Sharp.git) C# · 81 lines

52 public CudaKernel GetKernel(string name, string signature)

53 {

54 var pattern = new Regex(@"""^\s*(const)?\s*([\w_]+)\s*(\*)?\s*([\w_]+)?\s*$""");

55 var args = Regex.Replace(signature, @"\s+", " ").Split(',');

AboutBox.Designer.cs (https://RegExMaster.svn.codeplex.com/svn) C# · 189 lines

1 namespace RegexMaster

2 {

3 partial class AboutBox

IPv4SubnetmaskOrCIDRValidator.cs (https://github.com/BornToBeRoot/NETworkManager.git) C# · 30 lines

13 var subnetmaskOrCidr = value as string;

14

15 if (subnetmaskOrCidr != null && Regex.IsMatch(subnetmaskOrCidr, RegexHelper.SubnetmaskRegex))

16 return ValidationResult.ValidResult;

17

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})(\]?)$");

74

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

1 namespace CrackSoft.RegExplore

2 {

3 partial class JumpToKeyDialog

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;

30

31 public DeobfuscatorInfo() : base(DEFAULT_REGEX) =>

32 dumpEmbeddedAssemblies = new BoolOption(null, MakeArgName("embedded"), "Dump embedded assemblies", true);

33

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

70 var cursor = ex.Data["cursor"] as Cursor ?? new Cursor(subject, 0, fileName);

71

72 var parts = Regex.Split(ex.Message, @"(?<=^\w+):");

73 if (parts.Length == 1)

74 {

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}");

37

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

13 var subnet = (value as string)?.Trim();

14

15 if (subnet != null && Regex.IsMatch(subnet, RegexHelper.IPv4AddressCidrRegex))

16 return ValidationResult.ValidResult;

17

18 if (subnet != null && Regex.IsMatch(subnet, RegexHelper.IPv4AddressSubnetmaskRegex))

19 return ValidationResult.ValidResult;

20

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";

18

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

183 string pattern = @"[A-Z]{1,2}\s{1}[0-9]{4}\s{1}[A-Z]{1,2}";

184

185 Match match = Regex.Match(regNum, pattern);

186

187 if (match.Success)

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

68 return false;

69 }

70 //Match match = classNameRegex.Match(ClassName);

71 //return match.Success;

72 }

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).";

20

50 {

51 Title = "Search type:",

52 Description = "Changes the way that the Regex engine tries to match the repetition."

53 };

54

ParserTests.cs (https://github.com/sebastienros/esprima-dotnet.git) C# · 191 lines

176

177 [Fact]

178 public void ThrowsErrorForInvalidRegExFlags()

179 {

180 var parser = new JavaScriptParser("/'/o//'///C//ÿ");

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

40 try

41 {

42 MatchCollection tmpMatch = Regex.Matches(TrackNumber, strReg);

43 return tmpMatch.Count > 0;

44 }

ImageLocalSaverTests.cs (https://github.com/chenzhongfang/MindMate.git) C# · 328 lines

44

45 Assert.IsTrue(html.Contains("srcOrig"));

46 int imgUpdated = Regex.Matches(html, "srcOrig", RegexOptions.IgnoreCase).Count;

47 Assert.AreEqual(79, imgUpdated);

48

49 int imgCount = Regex.Matches(html, "<img", RegexOptions.IgnoreCase).Count;

50 Assert.IsTrue(imgCount > imgUpdated);

51 }

79

80 Assert.IsTrue(html.Contains("srcOrig"));

81 int imgUpdated = Regex.Matches(html, "srcOrig", RegexOptions.IgnoreCase).Count;

82 Assert.AreEqual(79, imgUpdated);

83

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

54 }

55

56 dojo.currency.regexp = function(/*Object?*/options){

57 //

58 // summary:

71 // strict- strict parsing, false by default

72 // places- number of decimal places to accept. Default is defined by currency.

73 return dojo.number.regexp(dojo.currency._mixInDefaults(options)); // String

74 }

75

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);

13

14 /// <summary>

41 }

42

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];

129

131 continue;

132 else

133 foreach (Capture regexCapture in regexGroup.Captures)

134 AppendCapturedStylesForRegexCapture(regexCapture, currentIndex, styleName, capturedStyles);

165 CompiledLanguage nestedCompiledLanguage = languageCompiler.Compile(nestedLanguage);

166

167 Match regexMatch = nestedCompiledLanguage.Regex.Match(regexCapture.Value, 0, regexCapture.Value.Length);

168

169 if (!regexMatch.Success)

182 }

183

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}$");

231

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;

24

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

1 namespace EdlinSoftware.RegexTester

2 {

3 partial class AboutForm

49 pbMe.BackgroundImage = null;

50 pbMe.Font = null;

51 pbMe.Image = global::EdlinSoftware.RegexTester.Properties.Resources.Me;

52 pbMe.ImageLocation = null;

53 pbMe.Name = "pbMe";

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}";

37

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.

611 =item B<maybe_regex>

612

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"

666

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);

23

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

118 try

119 {

120 if (string.IsNullOrWhiteSpace(RestApi) || !Regex.IsMatch(RestApi, @"^https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]$"))

121 {

122 _dialogService.ShowMessage("Please check the rest api and try again.", MessageButton.OK, MessageType.Error);

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;

49

50 Regex regex = new Regex("^(\\d+)");

51 Match xMatch = regex.Match(x);

52 Match yMatch = regex.Match(y);

53

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]+");

51

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]");

56

57 /// <summary>

ConsoleIO.cs (https://github.com/caphindsight/TrulyQuantumChess.git) C# · 180 lines

23 string move_str = Console.ReadLine();

24

25 string capitulate_move_regex = @"^(quit|exit|capitulate)$";

26 string agree_to_tie_move_regex = @"^tie$";

29 string castle_move_regex = @"^castle (left|right)$";

30

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);

34

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", "");

51

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+)";

21

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

39 NullExpected,

40

41 /// <summary>The Regex pattern does not match. </summary>

42 PatternMismatch,

43

85

86 /// <summary>An IP v6 address is expected. </summary>

87 IpV6Expected,

88

89 /// <summary>A valid GUID is expected. </summary>

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";

35

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);