Re: False positives in editing data
- From: RichardOnRails <RichardDummyMailbox58407@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 18:01:28 -0800 (PST)
On Nov 19, 2:42 am, Harry Kakueki <list.p...@xxxxxxxxx> wrote:
Problem solved!
I went through a convoluted process to determine whether any of the
initial numbers began with a zero. I simplified it to:
i_thNumberHasLeadingZero = (n[i] =~ /^0+/) ? true : false
I apologize for raising the question. My excuse is that I was
flailing about unable to figure out what was wrong. After I posted,
I took a harder look and realized my big mistake: I needed to use the
KISS method :-)
Best wishes,
Richard
If you solved your problem then you won't need this.
But, just in case you are interested in looking at it from a little
different view....
It is not a complete solution, just an idea.
inp = <<DATA
05Topic 5
1Topic 1
2.002.1Topic 2.2.1
2.1Topic 2.1
2.2.02Topic 2.2.2
DATA
err1 = inp.select{|a| a =~ /^0|\.0/}
puts "A number may not start with zero" unless err1.empty?
print err1
puts
err2 = inp.select{|b| b =~ /^\d+\.\d+\.\d/}
puts "No more that two numbers may be prefixed" unless err2.empty?
print err2
Harry
--
A Look into Japanese Ruby List in Englishhttp://www.kakueki.com/ruby/list.html
Hi Ryan,
But, just in case you are interested in looking at it from a little
different view....
It is not a complete solution, just an idea.
I AM interested, and it's a great idea. Real Ruby rather than my C-
flavored Ruby :-)
Just for our mutual amusement, I replaced your first criterion:
err1 = inp.select{|a| a =~ /^0|\.0/}
with:
err1 = inp.select{|a| a =~ /^0|^\d*\.0/}
to preclude false hits where the text proper might contain ".0", e.g.,
"7How to get 5.05% interest"
Bottom line: Your code is what I really need. Thanks, again.
Best wishes,
Richard
.
- Follow-Ups:
- Re: False positives in editing data
- From: Harry Kakueki
- Re: False positives in editing data
- References:
- False positives in editing data
- From: RichardOnRails
- Re: False positives in editing data
- From: RichardOnRails
- Re: False positives in editing data
- From: Harry Kakueki
- False positives in editing data
- Prev by Date: Re: Scientific Ruby (was Re: enterprise ruby)
- Next by Date: Re: Using irb as a REPL
- Previous by thread: Re: False positives in editing data
- Next by thread: Re: False positives in editing data
- Index(es):
Relevant Pages
|
|