Comments (8)
Working!
Note that $3
does not need to be quoted.
You also can use non-capturing parenthesis around the groups you don't want to capture, then use print $1
:
perl -ne '/^Help on (?:.+ in )*(?:module|package) (.*)(?=:$)/ and print $1'
Just an FYI.
from eless.
Or instead of using Perl regexes (-P), just use perl
That's interesting.. didn't think of that.
Also if you use egrep then you don't have to escape any of ()+.
I believe it's more canonical to use grep -E
instead of egrep
? In any case, I first became a fan of grep -E
(and sed -r
) and then grep -P
.
I'll have to find some time to research replacing the grep -P
and sed -r
.
Thanks for all that info.
from eless.
I believe it's more canonical to use grep -E instead of egrep?
Not sure.
from eless.
Note sure
Oh well, from man grep
(of course GNU grep):
In addition, two variant programs egrep and fgrep are available. egrep is
the same as grep -E. fgrep is the same as grep -F. Direct invocation as
either egrep or fgrep is deprecated, but is provided to allow historical
applications that rely on them to run unmodified.
from eless.
I'll need to spend some time understanding how to convert grep -Po ..
expressions to perl -ne ..
.
Help me out if you already have the answer :)
> echo "Help on Quitter in module _sitebuiltins object:" | \grep -Po '^Help on (.+ in )*(module|package) \K(.*)(?=:$)'
_sitebuiltins object
> echo "Help on Quitter in module _sitebuiltins object:" | \perl -ne '/^Help on (.+ in )*(module|package) \K(.*)(?=:$)/ and print'
Help on Quitter in module _sitebuiltins object:
Need to figure out out to make perl
return only the stuff after \K
and before (?= .. )
(that's what the -o
in grep
does.. and the -P
makes it understand \K
and look-ahead).
from eless.
OK, this worked:
echo "Help on Quitter in module _sitebuiltins object:" | \perl -ne '/^Help on (.+ in )*(module|package) (.*)(?=:$)/ and print "$3"'
from eless.
Please test the replace-grep-with-perl
branch.
from eless.
Note that $3 does not need to be quoted. You also can use non-capturing parenthesis around the groups you don't want to capture,
Thanks, of course. Completely forgot that elisp regexp is not the only place you could do that :)
from eless.
Related Issues (20)
- Make eless run on emacs 22.1 HOT 17
- Get emacs binary name from an env var HOT 2
- Replace sed -r s/foo/bar/I with BSD compatible equivalent HOT 2
- Fix building using "make all" on macOS HOT 12
- Invalid regex: "Invalid regular expression" error on macOS HOT 15
- Test various eless usage scenarios on Travis
- man pages are not readable on macOS HOT 79
- Support Perl man pages HOT 2
- Default theme HOT 2
- Installation instructions HOT 17
- View multiple files in sequence with eless HOT 1
- Document how markdown-mode can be installed to use eless as CLI md viewer
- man page with colors HOT 18
- Make the test for info .. | eless work on Travis HOT 3
- Customize faces HOT 3
- `make install` fails without meaningful error message if makeinfo is not installed HOT 2
- Error when filename has parentheses HOT 3
- Reconsider emacs dependency for brew formula HOT 3
- How can I use eless in vterm? HOT 1
- passing updated man page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eless.