Project

General

Profile

Actions

Bug #1572

closed

Regex range: upper range limit apparently not applied on digit matching

Bug #1572: Regex range: upper range limit apparently not applied on digit matching

Added by kugel (Thomas Martitz) over 16 years ago. Updated over 14 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.0 (2008-06-20 revision 17482) [i486-linux]
Backport:
[ruby-core:23716]

Description

=begin
I have this regex /fs[# ]{0,2}[\d]{3,6}/

Out of array = ["FS#", "FS#10048", "within a fs#10048 sentence", "fs# 9919", "fs100", "fs wow", "fs 1", "fs#132929921 "] it matches the array[1], array[2], array[3], array[4] and array[-1].

It shouldn't match the last element, as I maxed the repitions of \d to 6.
=end


Files

test.rb (1.37 KB) test.rb kugel (Thomas Martitz), 06/06/2009 12:58 AM

Updated by shyouhei (Shyouhei Urabe) over 16 years ago Actions #1

  • Status changed from Open to Rejected

=begin
Take a try to match /foo/ over "foo921 ".

It's a nature of a regex.
=end

Updated by nobu (Nobuyoshi Nakada) over 16 years ago Actions #2

=begin
Hi,

At Sat, 6 Jun 2009 00:58:23 +0900,
Thomas Martitz wrote in [ruby-core:23716]:

I have this regex /fs[# ]{0,2}[\d]{3,6}/

Use /fs[# ]{0,2}\d{3,6}(?!\d)/i or /fs[# ]{0,2}\d{3,6}\b/i.

--
Nobu Nakada

=end

Actions

Also available in: PDF Atom