Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Regex Optional capture doesn't

by Laurent_R (Canon)
on Oct 05, 2017 at 22:18 UTC ( #1200779=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      DB<1> $x = q|<blah1 phase="2" type="MyType" more_keys="Values" <Unwa
    +nted/>  <SomeTagIwant><k1="v1"></SomeTagIwant>|;
    
    ...
      DB<4> print "$_ " for  $y =~ /type="([^"]+)".+?(\\w+?TagIwant)  | ty
    +pe="([^"]+)"/x;;
      MyType
      DB<5> 
    
  2. or download this
      DB<6> $type = qr/type="([^"]+)"/;
    
    ...
    MyType SomeTagIwant
      DB<8> print "$_ " for $y  =~ /$type .+?(\w+?TagIwant) | $type /x;
      MyType
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1200779]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-12-17 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (466 votes). Check out past polls.

    Notices?