From: Ross Shaw Date: 2001-11-30T07:15:26+09:00 Subject: [ruby-talk:26975] Re: How to match '|' but not '\|' Doh, I've got this all wrong - just goes to show you need a compiler not a faulty memory. It should be something closer to this (although I suspect this is still wrong - I will check it again tonight). Hopefully there is enough here for someone to get the idea and set me straight. def test_string_split actual = 'Split|me|up\|into|four'.split (/??????/) expected = %w[Split me up\|into four] assert_equals(expected, actual) end Too early in the morning and in too much of a rush. Ross > I'm a bit of a nuby to regular expressions so I need a little assistance. > > I have a string that I want to split into separate words that are separated > by the pipe character '|'. However I do NOT want to split at points where > the pipe is preceded by a backslash '\|'. > > Here's a quick unit test. Can you fill in the missing regexp? > > def test_string_split > actual = 'Split|me|up\|into|four' (/??????/) > expected = %w[Split me up\into four] > assert_equals(expected, actual) > end > > Thanks > > Ross > > > >