tailieunhanh - Beginning Regular Expressions 2005 phần 8
Các tài sản lastIndex chứa giá trị của vị trí ký tự sau trận đấu trước đó. Khi các văn bản thử nghiệm Xin chào 99, giá trị của tài sản lastIndex là 8, bởi vì các trận đấu (chuỗi ký tự 99) bao gồm các vị trí ký tự 6 và 7. Khi các văn bản thử nghiệm là 99 Xin chào, giá trị của tài sản lastIndex 2, bởi vì trận đấu, 99, bao gồm vị trí ký tự 0 và 1, bởi vì chỉ mục bắt đầu từ 0. | C and Regular Expressions Method Description IsMatch Returns a Boolean value that indicates whether the regular expression pattern is matched in the string which is the argument to the IsMatch method. Match Returns zero or one Match object depending on whether the string supplied to the method as its argument contains a match. Matches Returns a MatchCollection object containing zero or more Match objects which contain all matches or none in the string that is the argument to the Matches method. Replace Replaces all occurrences of a regular expression pattern with a specified character sequence. Split Splits an input string into an array of strings. The split occurs at a position indicated by a regular expression pattern. ToString Returns a string containing the regular expression passed into the Regex object in its constructor. Unescape Unescapes any escaped characters in the input string. The CompileToAssembly Method The Regex class s CompileToAssembly method takes two arguments the RegexCompilationInfo object which is a member of the namespace and contains the information necessary to specify how compilation is to be carried out and the name of the assembly to be created. When the CompileToAssembly method is used the startup time can be expected to increase but with the benefit of faster running. The GetGroupNames Method The GetGroupNames method retrieves the names of any named groups associated with a Match object. The GetGroupNames method takes no argument. The GetGroupNumbers Method The GetGroupNumbers method retrieves the numbers of any numbered groups associated with a Match object. There is always at least one group which matches the entire regular expression pattern. If paired parentheses are included in the regular expression pattern there may be additional numbered groups. The GetGroupNumbers method takes no argument. GroupNumberFromName and GroupNameFromNumber Methods The GroupNumberFromName method retrieves a group number
đang nạp các trang xem trước