Hello,
I have this :
date = “2013 12 25”
year = /d{4}/.match(date)
puts “de gevonden jaar is #{year}”
But year stays empty.
Roelof
Hello,
I have this :
date = “2013 12 25”
year = /d{4}/.match(date)
puts “de gevonden jaar is #{year}”
But year stays empty.
Roelof
On Thursday 05 June 2014, 22:47:21, Roelof W.
wrote:
year = /d{4}/.match(date)
You’re searching for exactly 4 times the character “d”.
Hint: Character classes begin with a backslash.
HTH
--- Eric
p, li { white-space: pre-wrap; }On Thursday 05 June 2014, 22:47:21, Roelof W. wrote:
> year = /d{4}/.match(date)
You're searching for exactly 4 times the character "d".
Hint: Character classes begin with a backslash.
HTH
--- Eric
On Thursday 05 June 2014, 23:07:59, Roelof W. wrote:
#!/usr/local/bin/ruby -w
date = “2013 12 25”
year = /\d{4}/.match(date)
date2 = Date.new(year,12,24)And now this error message: main.rb:6:in `initialize’: wrong number of
arguments (3 for 0) (ArgumentError)
The “Date” class you want to use comes from the standard library; it is
contained in date.rb, which needs to be required.
I. e., your code is missing require 'date'
.
--- Eric
On Jun 5, 2014, at 14:07, Roelof W. [email protected] wrote:
#!/usr/local/bin/ruby -w
date = “2013 12 25”
year = /\d{4}/.match(date)
date2 = Date.new(year,12,24)
Looks like you got a bad error message. I get:
?> year = /\d{4}/.match(date)
=> #<MatchData “2013”>
date2 = Date.new(year,12,24)
NoMethodError: undefined method<' for #<MatchData "2013"> from (irb):5:in
new’
from (irb):5
from /usr/bin/irb:12:in `’
and that should hint better at what is going wrong. I’m using ruby 2.0
for the above.
P.S. I think you should read doco more before you go to the mailing list
for help.
UNSUBSCRIBE
ᐧ
Oliver Treadwell
USA (619) 890-3861 | Skype: OliTreadwell
[image: linkedin] [email protected][image: linkedin]
http://bit.ly/olitreadwell-linkedin[image: twitter]
http://bit.ly/olitreadwell-twitter
On Thu, Jun 5, 2014 at 3:50 PM, Eric MSP Veith
[email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs