in reply to Regular Expressions
use strict; use warnings; print map {qq{$_->[0] -- $_->[1] -- $_->[2]\n}} map { [ split m {(?x) (?: (?<=[a-z])(?=[^a-z]) | (?<=[^a-z])(?=[a-z]) ) } ] } map {chomp; $_} <DATA>; __END__ a=b a!=b a<b a<=b a>b a>=b
which gives this output
a -- = -- b a -- != -- b a -- < -- b a -- <= -- b a -- > -- b a -- >= -- b
Given a more complex set of operators you would probably be better off taking grinder's approach of setting up a regular expression that matches and captures any operator. As complexity increases a parser solution becomes more appropriate.
I hope this is of use.
Cheers,
JohnGG
|
|---|