Don't ask to ask, just ask | |
PerlMonks |
Minimizing the amount of place holders on long identical regexby thanos1983 (Parson) |
on Jun 20, 2018 at 15:53 UTC ( [id://1217011]=perlquestion: print w/replies, xml ) | Need Help?? |
thanos1983 has asked for the wisdom of the Perl Monks concerning the following question: I am really bad in regex and my best attempt that is working from my point of view is really poor in syntax. I am sure that it can be done in a different way and shorter. I am currently having a string that it is 24 numerical characters long and I have created a regex to split the string on pieces character by character so I can extract the odd place holders that contain the actual information that I need. What I have so far is:
This is the desired output and it is working but I was wondering if there is a more elegant way to minimize replicating the same group 24 times but also being able to get the odd place holders ($1$3$5...). I could use potentially split the string character by character and store the output in an array. Where from there I would remove the even elements and reform the array into string with join. But in my case this is not possible as the system that I am writing the regex does not support the split function or join it only supports C format commands syntax, so I am using Perl as a test tool before implementation. If any one has any idea how to make this regex shorter feel free to drop a comment. Thanks in advance for your time and effort, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
Back to
Seekers of Perl Wisdom
|
|