Using Regex number patternSSsuhas setty13yAsked Jun 25, 2013, 3:58 AM EDTSolvedShareLinkedInXCopy linkSaveHi want regular expression to check this kind 33.0.123 / 33.build.001 in a single expresion
Using Regex number patternSSsuhas setty13yAsked Jun 25, 2013, 3:58 AM EDTSolvedShareLinkedInXCopy linkSaveHi want regular expression to check this kind 33.0.123 / 33.build.001 in a single expresion
IHIftikar HussainRank #423 · 5.9K reputation13y agoPosted Jun 25, 2013, 4:22 AM EDT✓ Accepted answer0Hi, You can use like this Regex re = new Regex(@"^(33.)(0|build)(.)(\d{3})+$"); if (re.IsMatch(value)) MessageBox.Show("Matched"); else MessageBox.Show("Doesn't Matched");Example - Matched: 33.0.123,33.0.111,33.0.001,33.build.123,33.build.111,33.build.001Let me know if you need more detailsRegards,IftikarRemember to click "Mark as Answer" on the post, if it helps you.0
VulpesRank #55 · 29.2K reputation13y agoPosted Jun 25, 2013, 4:08 AM EDT0Try:using System;using System.Text.RegularExpressions;class Test{ static void Main() { string text = "33.0.123 / 33.build.001"; string regExp = @"^\d\d\.\d\.\d\d\d / \d\d\.build\.\d\d\d$"; bool isMatch = Regex.IsMatch(text, regExp); Console.WriteLine(isMatch); // True Console.ReadKey(); }} 0
SSsuhas setty137 reputation13y agoPosted Jun 25, 2013, 9:14 PM EDT0those build no should be read from text file example.txt33.0.123 loading "apple\folder1\folder2" loading "bat\folder3\folder4" unloaded "cat\fold5\fold6"33.build.002loading "apple\folder1\folder2" loading "bat\folder3\folder4" unloaded "cat\fold5\fold6" 33.0.122 loading "apple\folder1\folder2" loading "bat\folder3\folder4" unloaded "cat\fold5\fold6" 33.0.121 loading "apple\folder1\folder2" loading "bat\folder3\folder4" unloaded "cat\fold5\fold6"and i want only loading part0
VulpesRank #55 · 29.2K reputation13y agoPosted Jun 26, 2013, 4:01 AM EDT0Try the following:using System;using System.Text.RegularExpressions;using System.IO;class Program{ static void Main() { string text = File.ReadAllText("example2.txt"); string regExp = @"(?s)((\d{2}\.(\d|build)\.\d{3}).*?loading ""(.+?)"".*?loading ""(.+?)"")"; MatchCollection mc = Regex.Matches(text, regExp); foreach(Match m in mc) { Console.WriteLine(m.Groups[2].Value); Console.WriteLine(m.Groups[4].Value); Console.WriteLine(m.Groups[5].Value); Console.WriteLine(); } Console.ReadKey(); }}The output should be:33.0.123apple\folder1\folder2bat\folder3\folder433.build.002apple\folder1\folder2bat\folder3\folder433.0.122apple\folder1\folder2bat\folder3\folder433.0.121apple\folder1\folder2bat\folder3\folder40Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 25, 2013, 4:22 AM EDT
You can use like this
Regex re = new Regex(@"^(33.)(0|build)(.)(\d{3})+$");
Example -
Matched: 33.0.123,33.0.111,33.0.001,33.build.123,33.build.111,33.build.001
Let me know if you need more details
Regards,
Iftikar
Remember to click "Mark as Answer" on the post, if it helps you.
VulpesRank #55 · 29.2K reputationPosted Jun 25, 2013, 4:08 AM EDT
suhas setty137 reputationPosted Jun 25, 2013, 9:14 PM EDT
33.0.123
loading "apple\folder1\folder2"
loading "bat\folder3\folder4"
unloaded "cat\fold5\fold6"
33.build.002
loading "apple\folder1\folder2"
loading "bat\folder3\folder4"
unloaded "cat\fold5\fold6"
33.0.122
loading "apple\folder1\folder2"
loading "bat\folder3\folder4"
unloaded "cat\fold5\fold6"
33.0.121
loading "apple\folder1\folder2"
loading "bat\folder3\folder4"
unloaded "cat\fold5\fold6"
and i want only loading part
VulpesRank #55 · 29.2K reputationPosted Jun 26, 2013, 4:01 AM EDT
The output should be:
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts