For example, Oniguruma supports named captures (per this thread) and
zero-width negative lookbehind assertions, and ... more.
Certainly the syntax is different for new features, which cause the
current regexp engine to barf. Do you mean syntax inside the regex? Or
the syntax for declaring a regex? Or are you interested only in
backwards compatibility?
···
On Aug 20, 4:00 pm, Ari Brown <a...@aribrown.com> wrote:
I've read about Oniguruma - is it just a different engine behind
class Regex, and it won't change the syntax, right?
Because there's a Regexp wrapper I'm writing (with much help from
Robert Klemme) that uses Regex as the base, and all of the current
syntax.
For example, Oniguruma supports named captures (per this thread) and
zero-width negative lookbehind assertions, and ... more.
Certainly the syntax is different for new features, which cause the
current regexp engine to barf. Do you mean syntax inside the regex? Or
the syntax for declaring a regex? Or are you interested only in
backwards compatibility?
So yea, just backwards compatibility.
Is Oniguruma behind a new class Oniguruma.new or behind Regexp.new
Sorry, but I can't seem to find much documentation on it.
Ari
-------------------------------------------|
Nietzsche is my copilot
# I need some help in simplefying my life
# I need to create lots of tables from arrays and I need to provide
# each of the columns with a heading. For eample, I have
# two headings "a-value" and "b-value" specified as follows:
a = ["a-value", "b-value"]
b = [10, 10]
# The array b contains the width of the field, so that I get:
# a-value b-value
# Two ways to do this are as follows:
puts "#{'a-value'.rjust(10)}#{'b-value'.rjust(10)}"
puts "#{a[0].rjust(b[0])}#{a[1].rjust(b[1])}"
# which is difficult to debug, so that I'm looking for
# a simpler process, specificaly by writing a function.
# The following one works:
def heading2(x, n)
x.length.times do |i|
print "#{x[i].rjust(n[i])}"
end
print "\n\n"
end
puts
heading2(a,b)
# But this approach doesn't. Why not? Are there other ways to make this simpler?
def heading1(x, n)
s = ""
x.length.times do |i|
s = s + "\#{\'" + x[i] + "\'.rjust(" + n[i].to_s + ")}"
end
p s
print s
puts s
return s
end
I believe that under 1.8 it comes as its own class, but in 1.9 on it
is the code behind the builtin Regexp class. (I could be wrong,
though. There may be a way to build 1.8 using Oniguruma as the basis
for Regexp.)
And, from what I know, all regex features available in 1.8 use the
same syntax in Oniguruma.
···
On Aug 20, 5:17 pm, Ari Brown <a...@aribrown.com> wrote:
On Aug 20, 2007, at 6:10 PM, Phrogz wrote:
> What do you mean by "change the syntax"?
I mean change the basic regexp syntax.
> For example, Oniguruma supports named captures (per this thread) and
> zero-width negative lookbehind assertions, and ... more.
> Certainly the syntax is different for new features, which cause the
> current regexp engine to barf. Do you mean syntax inside the regex? Or
> the syntax for declaring a regex? Or are you interested only in
> backwards compatibility?
So yea, just backwards compatibility.
Is Oniguruma behind a new class Oniguruma.new or behind Regexp.new
Sorry, but I can't seem to find much documentation on it.
On Aug 22, 2007, at 7:21 AM, Peter Versteegen wrote:
# Hi,
# I need some help in simplefying my life
# I need to create lots of tables from arrays and I need to provide
# each of the columns with a heading. For eample, I have
# two headings "a-value" and "b-value" specified as follows:
a = ["a-value", "b-value"]
b = [10, 10]
# The array b contains the width of the field, so that I get:
# a-value b-value
# Two ways to do this are as follows:
puts "#{'a-value'.rjust(10)}#{'b-value'.rjust(10)}"
puts "#{a[0].rjust(b[0])}#{a[1].rjust(b[1])}"
# which is difficult to debug, so that I'm looking for
# a simpler process, specificaly by writing a function.
# The following one works:
def heading2(x, n)
x.length.times do |i|
print "#{x[i].rjust(n[i])}"
end
print "\n\n"
end
puts
heading2(a,b)
# But this approach doesn't. Why not? Are there other ways to make this simpler?
def heading1(x, n)
s = ""
x.length.times do |i|
s = s + "\#{\'" + x[i] + "\'.rjust(" + n[i].to_s + ")}"
end
p s
print s
puts s
return s
end
Thanks, this works also. The result is put in a string and the string is printed.
I guess what I was trying to do is to create a string that ruby is supposed to interpret, or execute. Perhaps there is another command to accomplish this.
Peter
···
On Aug 22, 2007, at 8:07 AM, Douglas F Shearer wrote:
Hi Peter.
On 22 Aug 2007, at 12:21, Peter Versteegen wrote:
# But this approach doesn't. Why not? Are there other ways to make this simpler?
Maybe I've got the wrong end of the stick on this, but I get it to work like this:
==========================
a = ["a-value","b-value", "c-value"]
b = [10,30,15]
def header(names, widths)
header = ''
names.each_with_index do |v,i|
header += v.rjust widths[i]
end
header
end
Had not come across Ruport. Sounds interesting, especially since I have to do a lot of reporting. I will investigate further.
Thanks,
Peter
···
On Aug 22, 2007, at 3:10 PM, Ari Brown wrote:
Ruby Reports. Ruport. Check it out.
On Aug 22, 2007, at 7:21 AM, Peter Versteegen wrote:
# Hi,
# I need some help in simplefying my life
# I need to create lots of tables from arrays and I need to provide
# each of the columns with a heading. For eample, I have
# two headings "a-value" and "b-value" specified as follows:
a = ["a-value", "b-value"]
b = [10, 10]
# The array b contains the width of the field, so that I get:
# a-value b-value
# Two ways to do this are as follows:
puts "#{'a-value'.rjust(10)}#{'b-value'.rjust(10)}"
puts "#{a[0].rjust(b[0])}#{a[1].rjust(b[1])}"
# which is difficult to debug, so that I'm looking for
# a simpler process, specificaly by writing a function.
# The following one works:
def heading2(x, n)
x.length.times do |i|
print "#{x[i].rjust(n[i])}"
end
print "\n\n"
end
puts
heading2(a,b)
# But this approach doesn't. Why not? Are there other ways to make this simpler?
def heading1(x, n)
s = ""
x.length.times do |i|
s = s + "\#{\'" + x[i] + "\'.rjust(" + n[i].to_s + ")}"
end
p s
print s
puts s
return s
end