regex - Regular expression circular matching -


using regular expressions (in language) there way match pattern wraps around end beginning of string? example, if want match pattern:

"street"

against string:

m = "et stre"

it match m[3:] + m[:2]

you can't directly in regexp. can arithmetic. append string itself:

m = "et stre" n = m + m //n = "et street stre" 

if there odd number of matches in n (in case, 1), match 'circular'. if not, there no circular matches, , number of matches in n double of number of matches in m.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -