ah ok thank you all for your help
On 22 sep, 14:36, deegee <[EMAIL PROTECTED]> wrote: > Regexp.match(string) will return you a MatchData object, which is not > just the match: It can be accessed as an Array. So: > sub[0] returns the entire matched string > sub[1], sub[2], ... return the values of the matched back references > (the ones between parentheses). > > sub[1] is therefore the thing you want to use. No need to use to_s. > > On 22 sep, 14:20, jef <[EMAIL PROTECTED]> wrote: > > > hi > > > /.*<coordinates>(.*)<\/coordinates>.*/ The reg exp you gave works > > fine. I tested it with rubular > > > probleme I can retrieve the substring I always get the whole string. > > > Here is what i did: > > > irb(main):001:0> st="<Point><coordinates>-0.954850,46.436960,0</ > > coordinates></Point>" > > => "<Point><coordinates>-0.954850,46.436960,0</coordinates></Point>" > > irb(main):002:0> sub=/.*<coordinates>(.*)<\/coordinates>.*/.match(st) > > => #<MatchData:0x7f2040045fd0> > > irb(main):003:0> sub.inspect > > => "#<MatchData:0x7f2040045fd0>" > > irb(main):004:0> sub.to_s > > => "<Point><coordinates>-0.954850,46.436960,0</coordinates></Point>" > > irb(main):005:0> sub.string > > => "<Point><coordinates>-0.954850,46.436960,0</coordinates></Point>" > > irb(main):006:0> st.match(/.*<coordinates>(.*)<\/coordinates>.*/) > > => #<MatchData:0x7f2040019fc0> > > irb(main):007:0> st.match(/.*<coordinates>(.*)<\/coordinates>.*/).to_s > > => "<Point><coordinates>-0.954850,46.436960,0</coordinates></Point>" > > > thank you for your help > > > : --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

