--
You received this message because you are subscribed to the Google Groups "Kerala Ruby Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kerala-ruby-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello, did you understand how it works ?
--
Twitter: http://twitter.com/keralarb
Website: http://krug.github.io
IRC: #krug.rb, freenode
---
You received this message because you are subscribed to the Google Groups "Kerala Ruby Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kerala-ruby-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Twitter: http://twitter.com/keralarb
Website: http://krug.github.io
IRC: #krug.rb, freenode
---
You received this message because you are subscribed to the Google Groups "Kerala Ruby Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kerala-ruby-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@Revath : I should really say that the post is really descriptive. Nicely presented. I think I can help in making certain parts clear (taking in consideration, that you mentioned you are writing what you understood), or maybe I have got it wrong. Anyway here they are :
"The Grouping start with ?= means its a positive lookahead and the previously captured match (matched by group 1) should follow match of this group. Whatever this Group 2 matches won't expand the match of Group 1. Whatever this Group 2 matches won't expand the match of Group 1."
I think it isn't a good idea to say that the previously captured match should follow the match of the positive lookahead group. Afaik, every consecutive group match is done right after the previous one. The match actually expands, i.e if the number is 45000, the whole match is 45000. But it will not be added to the actual MATCHED TEXT (this is the core speciality of lookaheads. should be mentioned instead).
"(?!\d) is a negative lookahead which succeeds when the regex inside lookahead fails. This helps to filter out last 3 digits of a number."
Imo, the regex inside lookahead succeeds means that there isn't any digit following the previous match. It fails means there is a digit following, then the negative lookahead should fail.
Also it isn't just last three digits of a number. It's to ensure that there are exactly odd number of digits remaining after the previous match. But you have given that idea clearly in the later parts.
"So with String#gsub we can replace the content of group 1 with <content of group1>,, ie., we can replace 12 with 12, and 34 with 34,."
Actually it's the MATCHED DATA that is being replaced not the content of 1st capture group.
Hope it helps.
--
Twitter: http://twitter.com/keralarb
Website: http://krug.github.io
IRC: #krug.rb, freenode
---
You received this message because you are subscribed to the Google Groups "Kerala Ruby Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kerala-ruby-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.