puts( /^[a-z 0-9]*$/ =~ 'Well hello 123' ) # no match due to ^ and
uppercase 'W'
puts( /^[a-z 0-9]*/ =~ 'Well hello 123' ) # * zero (or more) matches at
start ^ = 0
i could barely understand why the existence of $ makes such a
difference.
any help?
···
--
Posted via http://www.ruby-forum.com/ .
puts( /[a-z 0-9]*$/ =~ 'Well hello 123' ) # no ^, so match made at char
1 'e'
puts( /[a-z 0-9]$/ =~ 'Well hello 123' ) # $ match from end = 13
so as this one,why does * makes such a difference?
···
--
Posted via http://www.ruby-forum.com/ .
Victor_D
(Victor D.)
21 November 2010 06:04
3
i could barely understand why the existence of $ makes such a
difference.
any help?
/^[a-z 0-9]*$/ must match the whole string (and it can't due to
uppercase 'W'
/^[a-z 0-9]*/ may match only empty string at the beginning (and it does)
Why don't you play with it at rubular.com for a while, it will help you to
see easier what is happening when you change your regexp.
···
On Sat, Nov 20, 2010 at 7:41 PM, Stanford Ng <ngkooinam@gmail.com> wrote:
puts( /^[a-z 0-9]*$/ =~ 'Well hello 123' ) # no match due to ^ and
uppercase 'W'
puts( /^[a-z 0-9]*/ =~ 'Well hello 123' ) # * zero (or more) matches at
start ^ = 0
i could barely understand why the existence of $ makes such a
difference.
any help?
--
Posted via http://www.ruby-forum.com/\ .
dudes,i am really confused with this.
could someone elaborate more on this?
/^\s*#/
···
--
Posted via http://www.ruby-forum.com/ .
pal,i think i need more elaborate on these two expressions if possible.
/^[a-z]*/
/[a-z]*$/
please
···
--
Posted via http://www.ruby-forum.com/ .
i think i roughly understand by now.
thanks for your help
···
--
Posted via http://www.ruby-forum.com/ .
AbbyBooth
(AbbyBooth)
9 December 2010 09:50
8
Some time ago, I needed to buy a good car for my firm but I didn't have enough money and could not purchase anything. Thank goodness my friend proposed to take the <a href="http://bestfinance-blog.com/topics/home-loans ">home loans</a> at trustworthy bank. Thence, I did so and used to be satisfied with my commercial loan.
Victor_D
(Victor D.)
21 November 2010 06:10
9
puts( /[a-z 0-9]$/ =~ 'Well hello 123' ) # $ match from end = 13
so as this one,why does * makes such a difference?
Without * regexp may match only one char at the end of the string.
Could you elaborate on what has you confused? What do you expect it to
match? What text are you matching it against? What methods are using it and
how are you calling them?
···
On Sun, Nov 21, 2010 at 7:59 AM, Stanford Ng <ngkooinam@gmail.com> wrote:
dudes,i am really confused with this.
could someone elaborate more on this?
/^\s*#/
--
Posted via http://www.ruby-forum.com/\ .
Ammar_Ali
(Ammar Ali)
21 November 2010 14:20
11
pal,i think i need more elaborate on these two expressions if possible.
/^[a-z]*/
/[a-z]*$/
please
This might help. The following two expressions are matching the same thing:
'Well hello 123' =~ /^[a-z]*/
=> 0
'Well hello 123' =~ /^/
=> 0
Same here:
'Well hello 123' =~ /[a-z]*$/
=> 14
'Well hello 123' =~ /$/
=> 14
For more details, take a look at the matched data
/^[a-z]*/.match('Well hello 123').to_a
=> [""]
/[a-z]*$/.match('Well hello 123').to_a
=> [""]
HTH,
Ammar
···
On Sun, Nov 21, 2010 at 4:11 PM, Stanford Ng <ngkooinam@gmail.com> wrote:
Robert_K1
(Robert K.)
21 November 2010 15:20
12
Please don't write "need" and ask specific questions. It's just too broad a question you are posing here. People could write books in answer to this. See also:
http://www.catb.org/~esr/faqs/smart-questions.html
Kind regards
robert
···
On 21.11.2010 15:11, Stanford Ng wrote:
pal,i think i need more elaborate on these two expressions if possible.
/^[a-z]*/
/[a-z]*$/
please
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/