in reply to Problem with RegEx & various "endings"

Maybe I don't understand correctly...but what about
$teststring =~ /^[[]?([^] _]+)/;
this puts in $1 the first word of the string, where "word" means "the first sequence of letters ended by "]", " " or "_". Add other delimiters if needed. In the case of "]", it also checks for an optional leading "[".

Replies are listed 'Best First'.
Re^2: Problem with RegEx & various "endings"
by timesink (Initiate) on Jul 01, 2008 at 14:36 UTC
    thanks for your solution :)
    With the help of apl & another programmer I came up with a similar solution but I will compare both and see which one is better (probably not mine :()

    And I'm really sorry if I didn't ask clearly enough :(