in reply to use regex to split sentence

Its much easier to use split:

$_ = "X1aaX2bbX3heeX4...X5loveU"; @match = split (/X\d/,$_);

Replies are listed 'Best First'.
Re: Re: use regex to split sentence
by dyno (Initiate) on Nov 01, 2002 at 07:15 UTC
    That's not what I want.
    aa bb hee ... loveU
    in fact I realy want to know what pattern can match the result I expected--I mean below:
    X1aa X2bb X3hee X4... X5loveU

      Try this:

      @match = /X\d[^X]+/g;

      Basically it slurps up everything that's not an 'X' after doing matching 'X\d'.

        thanks. in fact, it could be "X1XloveU".and I want it to be matched. this is just a simplified example about my work.
        in fact, 'X\d'could follow any string apart from 'X\d'. i.e.it could be "X1XXXIloveU". This is just a simplified example about my work. Any idea not let * eat all words followed?