From: "Weirich, James" Date: 2004-01-15T03:25:14+09:00 Subject: Re: Converting a string to an array of tokens (TestCase Attached) > From: Robert Klemme [mailto:bob.news@gmx.net] > > Try /./ instead of /.*/. Unexpected stuff will come at you one > character at a time, which may or may not be ok. > > Looks like "|.*" is already present above. Or did you want > to point to something else? Ummm ... I was suggesting "|." *instead* of "|.*" irb(main):001:0> "foo bar baz".scan(/foo|bar|./) ["foo", " ", "bar", " ", "b", "a", "z"] See how the unexpected stuff comes at you one character at a time. This may or may not be a problem. > > For example, if all you are interested in are patterns > > like "some_var = some_thing_else", then end your token list with > > something like /[^a-zA-Z0-9_=]*/. > > Again I'd suggest to consider the "+" since the empty > sequence is not very often interesting as a token. Yes, "+" is a better option than "*". Another anoying feature of scan is this if you have parenthesis in your RE, then it starts returning lists of matches. -- -- Jim Weirich / Compuware -- FWP Capture Services -- Phone: 859-386-8855