#!/usr/bin/perl -w use strict; my $str = "x:= y + z;"; my @tokens = split /\s+|(?<=\w)(?=(?:;|:=))/, $str; print join "\n", @tokens; #### my @tokens = split / \s+ # whitespace | # or (?<=\w) # after a word character (?= # before a ..... (?: # non-backreferencing paranthesis (to prevent adding matches to list returned) ; # a semicolon | # or := # colon equals; add more operators to split on after here ) ) /x, $str;