在ASCII 影像中,例如:
....X....... ..X..X...X.... X.X...X..X..... X....XXXXXX..... X..XXX........... .....X.......... ..............X ..X...........X.... ..X...........X....X... ....X.....
在ASCII 影像中,例如:
在ASCII 影像中,例如:(?xm) # ignore comments and whitespace, ^ matches beginning of line ^ # beginning of line (?: . # any character except \n (?= # lookahead .*+\n # go to next line ( ?+ . ) # add a character to the 1st capturing group .*+\n # next line ( ?+ . ) # add a character to the 2nd capturing group ) )*? # repeat as few times as needed X .*+\n # X on the first line and advance to next line ?+ # if 1st capturing group is defined, use it, consuming exactly the same number of characters as on the first line X .*+\n # X on the 2nd line and advance to next line ?+ # if 2st capturing group is defined, use it, consuming exactly the same number of characters as on the first line X # X on the 3rd line在ASCII 影像中,例如:
我們'我想找到一個由三個X 組成的簡單垂直線,而不使用除此之外的最佳方法正則表達式。 問題1:這樣的形式是否存在
問題2:計算這樣的編隊
^ (?: (?: # match .+? characters . (?= # counting the same number on the following two lines .*+\n ( ?+ . ) .*+\n ( ?+ . ) ) )+? (?<= X ) # till the above consumes an X (?= # that matches the following conditions .*+\n ?+ (?<= X ) .*+\n ?+ (?<= X ) ) (?= # count the number of matches .*+\n ( ?+ . ) # the number of matches = length of ) )* # repeat as long as there are matches on this line .*\n? # remove the rest of the line簡單匹配對於直接匹配並要求計數為匹配數,由於lookbehind支持有限,這個問題無法在PCRE或Perl中直接解。 長度/間接解但是,如果答案被接受為 a 的長度匹配或替換,則可以用以下表達式來回答:
以上是您可以使用正規表示式在 ASCII 影像中找到由三個“X”組成的垂直線嗎?的詳細內容。更多資訊請關注PHP中文網其他相關文章!