variables in regex

Discussion in 'Ruby' started by JCYoder@gmail.com, Sep 2, 2005.

  1. Guest

    Does anyone know how I can write a regular expression using a variable
    in a range?

    For example:
    string.scan(/(.{1, variable})(?: |$)/).join("\n")

    This generates the following error:
    warning: regexp has invalid interval
    warning: regexp has `}' without
    escape

    I have seen some postings where RegEx.quote(variable) is used but this
    does not seem to work in a range.
     
    , Sep 2, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    724
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,651
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    614
  4. Replies:
    9
    Views:
    987
  5. Replies:
    3
    Views:
    795
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page