Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nre doesn't document quantifiers `re"foo{2,4}"` #9470

Closed
timotheecour opened this issue Oct 23, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@timotheecour
Copy link
Contributor

commented Oct 23, 2018

nre doesn't support quantifiers re"foo{2,4}" [EDIT] it's not documented

it's supported by re, nim-regex (https://nitely.github.io/nim-regex/) and lots of regex libraries (eg https://dlang.org/phobos/std_regex.html)

x{n,m}   at least n x and at most m x (greedy)
x{n,}    at least n x (greedy)
x{n}     exactly n x
x{n,m}?  at least n x and at most m x (ungreedy/lazy)
x{n,}?   at least n x (ungreedy/lazy)
x{n}?    exactly n x

I'd rather just use nre as discussed elsewhere but this prevents from using it in some cases

note

assigned to @flaviut based on doc/codeowners.rst

@skilchen

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

Why do you think that nre doesn't support quantifiers. Please provide some examples of what you expect and what nre matches.

import nre
echo replace("fofoofooofobarfoofofoo", re"fo{1,3}", "")

produces:

bar

which seems correct to me.

@timotheecour timotheecour changed the title nre doesn't support quantifiers `re"foo{2,4}"` nre doesn't document quantifiers `re"foo{2,4}"` Oct 23, 2018

@timotheecour

This comment has been minimized.

Copy link
Contributor Author

commented Oct 23, 2018

ok great; changed title to nre doesn't document quantifiers re"foo{2,4}"
indeed, I don't see it documented anywhere in https://nim-lang.github.io/Nim/nre.html#contains%2Cstring%2CRegex%2Cint

without documentation it's not at all clear which quantifiers are available from all these:
x{n,m} at least n x and at most m x (greedy)
x{n,} at least n x (greedy)
x{n} exactly n x
x{n,m}? at least n x and at most m x (ungreedy/lazy)
x{n,}? at least n x (ungreedy/lazy)
x{n}? exactly n x

@skilchen

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

Reproducing the PCRE documentation in nre probably doesn't make sense.
I would recommend reading man pcresyntax or the relevant parts of http://pcre.sourceforge.net/pcre.txt

Btw. http://nim-lang.github.io/Nim/pcre.html is another example showing that either the doc-comments or the docgen have potential for improvements ...

@flaviut

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

I have no plan to reproduce the PCRE docs in nre, but I'll make a link to the syntax more prominent.

@timotheecour timotheecour added the regex label Oct 29, 2018

flaviut added a commit to flaviut/Nim that referenced this issue Nov 18, 2018

flaviut added a commit to flaviut/Nim that referenced this issue Nov 18, 2018

flaviut added a commit to flaviut/Nim that referenced this issue Nov 18, 2018

@flaviut flaviut closed this in ebcf940 Nov 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.