in reply to Re: regex help!
in thread regex help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex help!
by GrandFather (Saint) on Sep 15, 2005 at 20:50 UTC | |
It is important to show us the "crap" because that shows that you have at least made an effort. It is also important to show some of the data because a description may not be very clear. As you will have noticed from the earlier replies to your original message, we are inclined to grab an idea and run with it - even if it is hopelessly wrong. After all that lecturing, here is a solution for you (I suggest you examine this carefully, then reply explaining how you think it works):
Note that the sample data is given as part of the script so tht other monks can simply download the entire thing and run it to see that it works. The sample given prints:
Perl is Huffman encoded by design. | [reply] [d/l] [select] |
by igotlongestname (Acolyte) on Sep 16, 2005 at 15:30 UTC | |
What I couldn't figure out was how to get it to go to the line after the data that I found. (I realized the line above the data was a unique line and that I could search for it directly). An example of the output is as follows: The data extends longer across the page, but in the interest of width I didn't include all of it, it's just the same pattern repeated. Lastly, my attempt to understand your file: match according to NP, then white space, then U, then white space, then Pu ending ... case insensitive. Last if there is no more data? Also, next loop if there is a match? Is this what moves you to the next line down? Break up the current data into substrings, I can figure out what the nomenclature means although I don't know it offhand, I have books I can read it from. Print off the results. Again, thank you for the help, sorry for sucking at my posts early on, and any clarifications you would like to provide would be much appreciated. | [reply] [d/l] [select] |
by GrandFather (Saint) on Sep 16, 2005 at 23:31 UTC | |
Good post, you are getting the hang of it :). The substr stuff in my code uses the two special arrays @- and @+ which store the start and end points for the captures in the previous match. So, as you say the next if line skips the data line just read in the last if line, but when the header line didn't match. Don't worry about how bad your first post might be. You are learning fast and the other monks will smile at you as they pass in the hall. Perl is Huffman encoded by design. | [reply] [d/l] [select] |
|
Re^3: regex help!
by ww (Archbishop) on Sep 15, 2005 at 19:57 UTC | |
| [reply] [d/l] |