developzoom
Joined: 22 May 2016 Posts: 35
|
Posted: Wed Aug 31, 2016 6:22 pm Post subject: عبارا& |
|
|
[right]عبارات با قاعده در سی شارپ(Regular Expressions)
عبارت با قاعده، یک الگو است که می تواند با متن ورودی تطبیق داده شود. .Net framework یک موتور عبارت با قاعده فراهم کرده است که به چنین تطبیق هایی اجازه می دهد. الگوی متشکل از یک یا چند لیترال ، اپراتورها، یا ساختارها است.
تعریف عبارات با قاعده
دسته بندی های مختلف از کاراکترها، اپراتورها، و ساختارها وجود دارند که به شما اجازه می دهند تا عبارات منظم را تعریف کنید.
Character escapes
Character classes
Anchors
Grouping constructs
Quantifiers
Backreference constructs
Alternation constructs
Substitutions
Miscellaneous constructs
کلاس عبارت منظم (The Regex Class)
Regex class برای نشان دادن عبارت منظم استفاده می شود. روش استفاده از آن معمولی است و در زیر آمده است:
Sr.No Methods
۱ public bool IsMatch(string input)
Indicates whether the regular expression specified in the Regex constructor finds a match in a specified input string.
۲ public bool IsMatch(string input, int startat)
Indicates whether the regular expression specified in the Regex constructor finds a match in the specified input string, beginning at the specified starting position in the string.
۳ public static bool IsMatch(string input, string pattern)
Indicates whether the specified regular expression finds a match in the specified input string.
۴ public MatchCollection Matches(string input)
Searches the specified input string for all occurrences of a regular expression.
۵ public string Replace(string input, string replacement)
In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.
۶ public string[] Split(string input)
Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the Regex constructor.
برای مشاهده لیست کامل از متدها و خصوصیات، لطفا مستندات مایکروسافت در# C را مطالعه کنید.
آموزش برنامه نویسی[/right] _________________ چاپ دیجیتال |
|