^mkdir\s+(-p\s+)?/net/some/where$ does what you need. If you need non-capturning parentheses, use (?:-p\s+) instead of (-p\s+)
I tested the above using visual-regexp. Relevant Debian packages: visual-regexp, regexxer (which I didn't test). Since it took me few minutes to locate those packages, I'd like to use this opportunity to ask how do you discover Debian packages related to something (regular expressions in this case)? --- Omer On Mon, 2011-04-04 at 09:48 +0100, Avishalom Shalit wrote: > yes, of course add a space in there > ( -p)? > > -- vish > > > > On 4 April 2011 09:46, Yaron Golan <[email protected]> wrote: > > Thanks, > > your options counts that there are 2 white space between the 'mkdir' and the > > '/' which there will probably will be only 1... > > > > > > On Mon, Apr 4, 2011 at 11:42 AM, Avishalom Shalit <[email protected]> > > wrote: > >> > >> that is wrong because it includes "-" and "p" alone > >> > >> try (-p)? > >> or noncapturing parens if you care > >> -- vish > >> > >> > >> > >> On 4 April 2011 09:40, Yaron Golan <[email protected]> wrote: > >> > Hi all, > >> > I am trying to have the following 2 options valid into 1 REGEX, but not > >> > sure > >> > that this is the best way to do it. > >> > Please share your options. > >> > > >> > I wish that the following 2 strings will be valid: > >> > mkdir /net/some/where > >> > mkdir -p /net/some/where > >> > > >> > So far, the best REGEX I managed to come up with is: > >> > ^mkdir ?-?p? /net/some/where$ > >> > > >> > Is there a better way? > >> > I'd appreciate your answers ... -- May the holy trinity of $_, @_ and %_ be hallowed. My own blog is at http://www.zak.co.il/tddpirate/ My opinions, as expressed in this E-mail message, are mine alone. They do not represent the official policy of any organization with which I may be affiliated in any way. WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
