Help for this page
$regex = '(\w+)|(\d+)|(\s+)|([^\w\d\s]+)'; $text = 'The world is foo 2!'; ... print '\s+',$/ if $3; print '[^\w\d\s]+',$/ if $4; }
$regex = '(\w+)|(\d+)|(\s+)|([^\w\d\s]+)'; $text = 'The world is foo 2!'; ... print '\s+',$/ if defined $3; print '[^\w\d\s]+',$/ if defined $4; }