« first day (3256 days earlier)      last day (1992 days later) » 

01:33
I'm trying to use a regexp in less to find improperly formatted lines, but the ones I use with grep aren't working, I get an invalid pattern error. The manpage says:
/pattern
Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system. The search starts at the first line displayed (but see the -a and -j options, which change this).
How do I determine the regexp library supplied by system?
cas
cas
01:56
less uses extended regular expressions, same as grep -E (aka the deprecated egrep).
I don't think that's right
There are a pile of configuration macros defined HAVE_GNU_REGEX, HAVE_POSIX_REGCOMP, HAVE_PCRE2, HAVE_PCRE, HAVE_RE_COMP, HAVE_REGCMP, HAVE_V8_REGCOMP, and it uses different code according to its idea of which of those is the best available at build time
cas
cas
try man man and then search for \[+. + is magic in ERE, non-magic in BRE. /\[+ finds [ characters in less, so less uses ERE.
on pretty nearly any remotely-modern system, that means ERE. or PCRE (which is effectively a superset of ERE).
That's the question, isn't it
It makes an effort to select an ERE-like mode in whichever library it's using but there are a lot of libraries it supports
cas
cas
i don't think so. unless someone says that they're using some bizarre palaeo-unix with a primitive regex library, it's reasonable to assume they're using something vaguely modernish. (and, in many cases, it's reasonable to assume they're using gnu/linux unless they state otherwise)
02:11
It uses GNU if available, then POSIX regcomp, then PCRE, then PCRE2, ...
It's hard to imagine a current system getting as far as PCRE even
Actually the configure script could just undefine these out of order, so I don't know what the priority is. That's the order in the source though
cas
cas
it's even harder imagining a current system NOT stopping at GNU and getting ERE.
less uses ERE even in GNU-phobic FreeBSD ("ewww! don't touch that, it has license germs").
It gets ERE from POSIX regcomp
That part isn't in question
cas
cas
so, except in some very rare and/or unusual environments - mostly archaic, proprietary *nixes (which probably don't even have less installed by default), less uses ERE.
The priority order seems to be POSIX regcomp, pcre2, gnu, regcmp, V8 regcomp, a local V8 regcomp, then re_comp but only if you ask for it, then none. But POSIX regcomp is just back to "library supplied by your system"
It always tries to use ERE, but that isn't an answer to what the library actually is
You're overwhelmingly likely to be in the first case unless the distribution maintainer has Views
03:11
So, it's a kinda "usually it's this, but depends" situation?
In any case, I probably should have mentioned the regexp I was using: ^\+1[[:space:]]*$
I was betting on being able to use character classes
probably a dumb bet...
cas
cas
03:41
character classes work in less for me on debian (also on freebsd). what unix are you running less on?
btw, /^\+1\s*$ also works in less for me on debian, but not on freebsd. GNU's ERE understands perlish extensions like \s.
that should be "some perlish extensions, like \s" (but I was too late to edit and fix).
 
4 hours later…
07:45
@cas I believe it's only \s, \S, \w and \W.
Possibly \d and \D too, but I haven't checked the manual.
 
2 hours later…
09:34
Character classes are in POSIX, so they should work for most realistic variations
 
2 hours later…
11:09
@Ungeheuer It really would be so much better if you posted this sort of thing as a question on the main site instead of on chat.
When you ask in chat, nobody benefits but you. It's sort of like you're cheating the site of a good question.
 
4 hours later…
15:14
@terdon I didn't realize the answer to such a question would be so...undefined. Figured it'd be an "oh yea, it's always this" or a "check this environment variable"...should have learned by now that simple answers aren't common...
15:27
0
Q: Determining System Regular Expression Library

UngeheuerI was attempting to use the following regexp in less yesterday: ^\+1[[:space:]]*$, which worked for me in grep. This didn't work in less, so I checked the manpage to see what it does support, and found this: /pattern Search forward in the file for the N-th line containing the pattern. N defa...

@cas Fedora 30
 
1 hour later…
16:30
Aren't regular expressions somewhat language specific? Does the C library have one?
@Ungeheuer I think that less uses what C makes available on that particular platform. It could choose to use a custom regex library, but that would be an unusual choice.
Some programs do go with NIH, but most don't.
 
1 hour later…
18:00
@Ungeheuer great, thanks!
 
2 hours later…
19:49
0
Q: Why worker nodes are not fault-tolerant?

overexchangeA swarm manager nodes handles cluster management tasks such as: 1) Maintaining cluster state 2) Scheduling services 3) Serving swarm mode HTTP API endpoints You may execute any of the - docker swarm - docker node - docker service commands from any of the manager nodes Applications are r...

 
1 hour later…
21:11
@john I rejected your edit here because I thought you were only changing the for to forward which would completely change the meaning, but I hadn't realized you were fixing the format as well! I also failed to see that the original was pretty unclear in the first place. Anyway, sorry! I should have accepted the edit and improved it. My bad :/
21:36
Everybody makes mistakes. :)
Sometimes I go too far with edits.

« first day (3256 days earlier)      last day (1992 days later) »