From: Mike Meng Date: 2005-08-18T14:31:15+09:00 Subject: Novice Q: What's the difference between /\s*/ and /(\s)*/? Hi, I'm new to Ruby and reading 'Programming Ruby 2/e' now. I encountered a tricky problem while reading chapter 5, 'String" section. Here is the problem: # code line = '/jazz/j00319.mp3 | 2:58 | Louis Armstrong | Wonderful World' file, duration, artist, title = line.chomp.split(/\s*\|\s*/) # code end Run the code we get: file=='/jazz/j00319.mp3' duration=='2:58' artist=='Louis Armstrong' title=='Wonderful World' While if I change the regex pattern in 'split' to /(\s)*\|(\s)*/, that is, # code line = '/jazz/j00319.mp3 | 2:58 | Louis Armstrong | Wonderful World' file, duration, artist, title = line.chomp.split(/(\s)*\|(\s)*/) # code end We get: file=='/jazz/j00319.mp3' duration==' ' artist==' ' title=='2:58' What makes the differece? Any comments are appreciated.