Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How to extract special charachetrs like <=, >= != from string

by vinoth.ree (Monsignor)
on Aug 14, 2015 at 05:49 UTC ( [id://1138524]=note: print w/replies, xml ) Need Help??


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

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...

Replies are listed 'Best First'.
Re^3: How to extract special charachetrs like <=, >= != from string
by Anonymous Monk on Aug 14, 2015 at 08:13 UTC
    Hi all,

    Solution provided by james28909 did work for me.

    thanks --girija
Re^3: How to extract special charachetrs like <=, >= != from string
by james28909 (Deacon) on Aug 14, 2015 at 05:52 UTC
    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...
        For some reason I thought that meant the same character haha. I thought it would matched the character 'a' or 'aaaaa' not 'ab' or 'a3' ect. Anyways, i learn something new everyday I recon haha.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1138524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found