in reply to special regexp
From what I see, the only thing wrong with your regular expression is, that you don't allow for any characters between the last match and the next match. From your data, this regular expression works :
F:\>perl -ne "while (m/\G.*?x(.)(?=x)/g) { print $1; }" axbxxcxdsxxxtx bcxt
An interesting boundary case is xxxx - what do you expect to be printed ? My solution prints x, as it matches xxx and is then left with x, which does not match. Conceivably, xx would also be a solution, as you could first match xxx and then move to the second x and match xxx again.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: special regexp
by alfie (Pilgrim) on Mar 26, 2001 at 12:05 UTC | |
by danger (Priest) on Mar 26, 2001 at 12:30 UTC |