-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
803f7b8
commit cc34cda
Showing
8 changed files
with
162 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using System.Collections.Generic; | ||
|
||
namespace Lab6; | ||
|
||
public class RegexExamples | ||
{ | ||
public static List<Match> ValidatePhoneNumber(string input) | ||
{ | ||
string pattern = @"(?:\b\d{3}[-\s]?\d{2}[-\s]?\d{2}\b)"; | ||
Regex regex = new Regex(pattern); | ||
return GetMatchesWithPositions(input, regex); | ||
} | ||
|
||
public static List<Match> ValidateFullName(string input) | ||
{ | ||
string pattern = @"\b[А-ЯЁ][а-яё]*\s+[А-ЯЁ][а-яё]*\s+[А-ЯЁ][а-яё]*\b"; | ||
Regex regex = new Regex(pattern); | ||
return GetMatchesWithPositions(input, regex); | ||
} | ||
|
||
public static List<Match> ValidateLatitude(string input) | ||
{ | ||
string pattern = @"(?<!\d)[-]?(?:(?:0*[0-8]\d?)|(?:90))(?:\.\d+)?(?!\d)"; | ||
Regex regex = new Regex(pattern); | ||
return GetMatchesWithPositions(input, regex); | ||
} | ||
|
||
private static List<Match> GetMatchesWithPositions(string input, Regex regex) | ||
{ | ||
List<Match> matches = [.. regex.Matches(input).Cast<Match>()]; | ||
return matches; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.