Confusing Reader.FindSubMatch
#327
IsSkyfalls
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Trying to match "" in "!!!!!".
Regex:
!\[(.*?)]\((.+?)\)
Cursor is on 0th byte.
block.FindSubMatch
will advance 11 characters (length of match, line 558), which will place the cursor here: "!!!!!![abc] | (123)". The return value ofblock.FindSubMatch
will still be the expected {"","abc","123"}.The current implementation is very confusing to me without reading any code. Would it be better if it matches only from the cursor, instead of anywhere in the line? Prepending ^ in the regex would do the trick, so maybe documenting this feature better?
goldmark/text/reader.go
Lines 539 to 561 in 829d874
Beta Was this translation helpful? Give feedback.
All reactions