in reply to How to extract special charachetrs like <=, >= != from string

If all your trying to do is extract those specific characters, then this might work for you:
use strict; use warnings; while (<DATA>) { print "$1\n" if $_ =~ /(!=|<=|>=|==)/; } __DATA__ $this <= $that $this lt $that $this >= $that $this gt $that $this != $that $this ne $that $this == $that $this eq $that
I do suggest you read up on Regular Expressions as it will help you out tremendously on your journey :)

Replies are listed 'Best First'.
Re^2: How to extract special charachetrs like <=, >= != from string
by vinoth.ree (Monsignor) on Aug 14, 2015 at 05:49 UTC

    We can even shorten this with character class []

    use strict; use warnings; use Data::Dumper; while(<DATA>) { print "$1\n" if($_ =~ /([><=!]+)/g) } __DATA__ $this vinoth $that $this >= $that $this gt $that $this != $that $this ne $that $this == $that $this eq $that

    All is well. I learn by answering your questions...
      Hi all,

      Solution provided by james28909 did work for me.

      thanks --girija
      My question to this is, how does it know to print the = after the ><=! ? Maybe i am missing a key piece of data/knowledge which would not surprise me lol.
        Because of the +.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        actually, it matches also =>, <>, !!, <=>, or in fact any combination of these four characters. It says "match these characters, one or more times".
        If you want only one of the 4 characters followed by a single "=", you'd write [!<=>]=
        ++choroba

        james28909, It could be great if you read this line + Match 1 or more times from the link you shared Regular Expressions


        All is well. I learn by answering your questions...