On Monday 17 January 2005 04:40 pm, trans. (T. Onoma) wrote: | On Monday 17 January 2005 04:26 pm, Zach Dennis wrote: | | trans. (T. Onoma) wrote: | | > Let me painfully honest: I hate parsing, especially w/ regexp, and I | | > don't care if it's because I stupid and suck at it. It shouldn't have | | > to be this hair pulling! Anyway... Can some one please give the regular | | > expression to match the first square bracket's contents. In this case | | > it would be "Hello". | | > | | > s = <<-EOS | | > [Hello] | | > This [b]is[b.] a test. | | > [Hello.] | | > EOS | | | | The trick here is to make sure you are non-greedy. | | | | s =~ /\[([^\]]*)\]/ | | Thanks. I _see_ now why mine wasn't working, though I don't _understand_ | why it wasn't working. I was using the / /x extension, because I generally | like to space the parts my regexps out to read easier, but for some reason | that causes the above to match [b] instead. Oh well, I just won't do that. Oops scratch that. That's not the reason either (sigh). But I got it working now anyway. Thanks. T.