Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7307

Re: Ruby Regexp why this expression does not match?

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: Ruby Regexp why this expression does not match?
Date Sat, 3 Dec 2016 09:13:38 +0100
Lines 21
Message-ID <eafd5kFabknU1@mid.individual.net> (permalink)
References <8318472d-4632-4a06-b4c7-348316425ffa@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net oyI6BwZbjeCDuoOtcmRjog/gsfxavGz/UbQYjeB+JJnFTc5/I=
Cancel-Lock sha1:MwRabQNoLvH7zClVr7Zd86/6MIE=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0
In-Reply-To <8318472d-4632-4a06-b4c7-348316425ffa@googlegroups.com>
Xref csiph.com comp.lang.ruby:7307

Show key headers only | View raw


On 03.12.2016 05:51, vunangluc@gmail.com wrote:
> I want to use this regex to match any block comment (c-style) in a string.
> But why the below does not?
>
>
> rblockcmt = Regexp.new "/\\*[.\s]*?\\*/"  # match block comment
> p rblockcmt=~"/* 22/Nov - add fee update */"
>
> ==> nil

Because a dot is not special in a character class.

Btw. why do you use Regexp.new and not write the expression directly?

Cheers

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Ruby Regexp why this expression does not match? vunangluc@gmail.com - 2016-12-02 20:51 -0800
  Re: Ruby Regexp why this expression does not match? Robert Klemme <shortcutter@googlemail.com> - 2016-12-03 09:13 +0100
    Re: Ruby Regexp why this expression does not match? vunangluc@gmail.com - 2016-12-03 00:28 -0800
      Re: Ruby Regexp why this expression does not match? Robert Klemme <shortcutter@googlemail.com> - 2016-12-03 11:27 +0100

csiph-web