Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-04-2011, 08:37 PM
|
#1
|
Member
Registered: Sep 2010
Posts: 58
Rep:
|
Regex: word^ matches what?
This regular expression may be the key, when I try to understand
Code:
sudo apt-get install lamp-server^
The manual says
Quote:
... anchor the regular expression with a '^' or '$' character, or create a more specific regular expression.
|
But there is no example how it works.
Any tip is welcome! Thanks!
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
02-05-2011, 01:09 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
well ^ means that *start* of the line, and $ means the end. so it'd be ^lamp-server to match strings starting with that phrase. I've never seen regexes used with apt-get though, is that supposed to work?
|
|
|
02-05-2011, 05:23 PM
|
#3
|
Senior Member
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
|
@acid_kewpie, from the man-page:
Quote:
If no package matches the given expression and the expression contains one of '.', '?' or '*' then it is assumed to be a POSIX regular expression, and it is applied to all package names in the database. Any matches are then installed (or removed). Note that matching is done by substring so 'lo.*' matches 'how-lo' and 'lowest'. If this is undesired, anchor the regular expression with a '^' or '$' character, or create a more specific regular expression.
|
@lesca:
You might be interested in some basic regular expression stuff - they're quite useful this is, as the link's title says, a very brief introduction to them...
|
|
|
02-06-2011, 02:26 AM
|
#4
|
Member
Registered: Sep 2010
Posts: 58
Original Poster
Rep:
|
But I think "^" should be at the start of the expression. Why not?
|
|
|
02-06-2011, 02:49 AM
|
#5
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,392
|
Expression matching can be whatever Humpty Dumpty chooses it to mean.
Don't confuse it with regex - whatever that means ...
|
|
|
02-06-2011, 08:34 AM
|
#6
|
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
|
Quote:
Originally Posted by lesca
But I think "^" should be at the start of the expression. Why not?
|
Who said it shouldn't?
The apt-get man page assumes you are familiar with regular expressions, and if you were, you would know what ^ and $ mean.
^ means the beginning of the string, $ means the end.
For example, the regex "es" will match the word "t est", but "^es" will not, because the string doesn't start with "es".
|
|
|
02-06-2011, 11:03 PM
|
#7
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Rep: 
|
Quote:
Originally Posted by lesca
Code:
sudo apt-get install lamp-server^
|
I suppose better questions might be where did you see this and how do you know it's not an error? It sounds like apt-get uses "inspired by" POSIX regular expressions. It certainly wouldn't match anything as an extended POSIX regular expression; as a non-extended regular expression "^" is interpreted literally, but I doubt "^" is part of a normal package name.
Kevin Barry
Last edited by ta0kira; 02-06-2011 at 11:07 PM.
|
|
|
02-07-2011, 02:18 AM
|
#8
|
Member
Registered: Sep 2010
Posts: 58
Original Poster
Rep:
|
Thank you for your answer.
I am sure it's right, because I followed those steps here
|
|
|
02-07-2011, 04:16 AM
|
#9
|
Member
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360
Rep: 
|
According to this page
https://help.ubuntu.com/community/Tasksel
the '^' makes
sudo apt-get install lamp-server^
behave as an alternative to
sudo tasksel install lamp-server
|
|
2 members found this post helpful.
|
02-07-2011, 03:29 PM
|
#10
|
Senior Member
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
|
Quote:
Originally Posted by ta0kira
It sounds like apt-get uses "inspired by" POSIX regular expressions.
|
I dunno, the man-pages said it was treated as a POSIX regular expression. Did you have a particular reason to believe it doesn't behave the same way? 
|
|
|
All times are GMT -5. The time now is 07:57 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|