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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am trying to match a data structure with a regex. I'm new to regex, but have made a start. The structure consists of 5 character blocks, seperated by spaces. The 1st is always 'UFOFH', then there are a number of blocks containing digits 0-9 and the / character. There are anywhere between 4 to 27 of these blocks. An example with 20 such blocks is below:

UFOFH 33603 01231 /0000 0024/ 1024/ 2025/ 3027/ 4030/ 5025/ 6028/ 7060/ 8081/ 9098/ 0110/ 1107/ 2106/ 3102/ 4080/ 5065/ 6057/ <\p>

I have tried the below, and some varations (the # is the regex seperator):

print $mailbox =~ m#UFOFH ([0-9//]{5} ){4,27}#ig;

But this only returns the penultimate charcter block before the newline (eg. '5065/') I have played around with the brackets, finding that this only returns specific bits of the structure (eg. one set of numbers). How do I wite the regex to return the whole structure from the UFOFH all the way to the last 5 character block?

Thanks


In reply to Regex matching by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found