regex - Backreference before capture group -
i'm trying match text page x of x
can identify last page in document.
i've been playing around capture groups, , found regex page (\d*) of \1
works, except matches things such page 2 of 25
. ideally, i'd use page \1 of (\d*)
, guess regex engine doesn't support that.
i should note part of ocr job, can't rely on string endings, since pick characters (page 2 of 25la
, example)
anyone have tips?
use \d+
instead of \d*
. check end of digit using lookaround well.
page (\d+) of \1(?=\d)
Comments
Post a Comment