Lurker News

Comments (129) 40 threads

Show all comments

Showing thread 12 of 40

dana3211 reply#
One thing i've always missed from the Perl programming language is the regex operators.

You could do:

  my $var='foo foo bar and more bar foo!!!';

  if($var=~/(foo|bar)/g){  # does the variable contain foo or bar?

    print "foo! $1 removing foo..\n";

    # remove our value..

    $var=~s/$1//g;

  }
dana321#
Awesome job, i did a hack bootstrapping the tokenizer to do the same thing in php, didn't release it though.