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
Post a Comment