Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Regex Optional capture doesn't

by NetWallah (Canon)
on Oct 05, 2017 at 16:19 UTC ( #1200743=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    <blah1 phase="2" type="MyType" more_keys="Values" <Unwanted/>  <SomeTa
    +gIwant><k1="v1"></SomeTagIwant>
    
  2. or download this
    \btype="([^"]+)".+<(\w+TagIwant\b)
    
  3. or download this
     perl -E '$x=q|<blah1 phase="2" type="MyType" more_keys="Values" <Unwa
    +nted/>  <SomeTagIwant><k1="v1"></SomeTagIwant>|;  say for $x=~/\btype
    +="([^"]+)".+<(\w+TagIwant\b)?/'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1200743]
Approved by Perlbotics
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-06-21 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (117 votes). Check out past polls.

    Notices?