Re: Regular expression
- From: Robert Klemme <shortcutter@xxxxxxxxxxxxxx>
- Date: Fri, 29 May 2009 06:54:36 -0500
2009/5/29 Harry Kakueki <list.push@xxxxxxxxx>:
On Fri, May 29, 2009 at 5:48 PM, Brian Candler <b.candler@xxxxxxxxx> wrote:
I think you need a negative lookahead assertion.
* http://www.ruby-doc.org/docs/ProgrammingRuby/
* click on "The Ruby Language"
* scroll to "Extensions"
* look for (?!re)
irb(main):009:0> /^(.)(?!\1)(.)(?!\1|\2)(.)(\2)$/ =~ "abcb"
=> 0
irb(main):010:0> /^(.)(?!\1)(.)(?!\1|\2)(.)(\2)$/ =~ "abbb"
=> nil
I need to read that section carefully to be sure I understand.
But, I think that does the trick.
The problem with this approach is that it does not work for strings of
arbitrary length. Even if you adjust it to work for multiple lengths
you always have a fixed upper limit for which it can work.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
.
- Follow-Ups:
- Re: Regular expression
- From: Brian Candler
- Re: Regular expression
- References:
- Regular expression
- From: Harry Kakueki
- Re: Regular expression
- From: Brian Candler
- Re: Regular expression
- From: Harry Kakueki
- Regular expression
- Prev by Date: Using commandline for cvs-like commands and help?
- Next by Date: Re: Regular expression
- Previous by thread: Re: Regular expression
- Next by thread: Re: Regular expression
- Index(es):
Relevant Pages
|