Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > variables in regex

Thread Tools

variables in regex
Posts: n/a
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

I have seen some postings where RegEx.quote(variable) is used but this
does not seem to work in a range.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? Python 3 07-01-2008 03:06 PM
Put variables into member variables or function variables? C++ 9 03-23-2008 04:03 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Java regex imposture re: Perl regex compatibility Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM