in reply to Re^5: Regex Modification
in thread Regex Modification
Thnx for the reply.. Can pls explain how the pattern matching is being done?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Regex Modification
by AnomalousMonk (Archbishop) on Apr 14, 2013 at 07:13 UTC | |
Here is a further simplified (and tested) version of the regex. The $digits and $diffs package variables are no longer needed, so I'm a little happier with this version, but it still uses absolute capture group numbering and embedded code. I could perhaps use named captures to get around the numbering problem, but I don't see what I can do about the code. There are a few more comments that may be helpful, and davido's nice Perl Regular Expression Tester may be enlightening. I may get around to posting a more detailed commentary on the regex in the next couple of days.
| [reply] [d/l] [select] |
|
Re^7: Regex Modification
by AnomalousMonk (Archbishop) on Apr 16, 2013 at 10:02 UTC | |
Update: I finally realized that $1 in the
| [reply] [d/l] [select] |
|
Re^7: Regex Modification
by AnomalousMonk (Archbishop) on Apr 13, 2013 at 20:07 UTC | |
Below is an updated version of the regex. It is simplified a little, and an error is corrected. (Update: And it now matches something like 'x123-456789123-456x'.) I am still less than happy with it: it is over-complicated (Update: and it uses package variables), and it is not standalone because of its use of embedded capture groups that make it sensitive to the presence of other capture groups if it is used in combination with other regexes. In any event, it works. Please see the embedded comments for a brief explanation of how the regex works, and see perlre and perlretut for more detailed info. The m1() test function returns the number of matches in a string if called in scalar context, and a list of all the matching sub-strings if called in list context. If you have more questions, please let me know. As before, HTH. Code: Read more... (5 kB)
Output: Read more... (3 kB)
| [reply] [d/l] [select] |