Hello Marshall,
This is very interesting, but while I was testing my code last night I updated with a bit more complex data.
Sample of new update more complicated data:
my $str = "902 M 903 Textmessage 904 PO 905 S 906 VAS 907 10 908 3629
+909 85290200429/TYPE=thanos\@test.com 910 NA 911 NA 912 NA 913 NA 914
+ NA 917 0 918 NA 919 Wed,_01_Feb_2017_19:56:23_GMT 922 NA 923 PO 924
+NA 925 NA 926 07594d85 927 100 928 20170202035623000+08 929 201702020
+35623000+08 930 NA 931 85260531042/TYPE=thanos2\@test.2.com 932 1 934
+ 258;3259 920 NA 921 NA 935 NA 936 NA 938 NA 939 NA 940 thanos-local
+942 NA 944 NA 945 4880 946 NA 948 NA 950 454000000927816 953 NA 954 1
+3 955 5.3.0 956 NA 957 07594d85 958 NA 961 13 981 NA 982 0 983 852902
+00429/TYPE=thanos3\@test.3.com 984 Wed,_01_Feb_2017_19:56:23_GMT 985
+RegularThanos 986 TEST 987 NA 988 NA 991 NA 992 NA 993 NA 994 1234567
+89 995 NA 996 NA 997 NA 998 NA 603 0E552E92 602 0 617 NA 618 NA 621 N
+A This is a test line that I want to Capture2 635 NA 636 NA 637 NA 63
+8 NA 639 This is a test line that I want to Capture";
With the regex that you provided works perfect without the new string. I am really bad with regex so I can not really tell why. I think because it matches the first string that it founds and at the end of the string it stops.
In my case I need also to be able to detect white space characters in the string. So I need from the regex to detect the string between two integers with 3 digits each, but that also will be a problem due to the last integer at the end of the string that has no integers following.
My temporary solution is:
@pairs = split(/(?:^|\s+)(\d{3})\s+/, $str);
After that I need to clear the array elements for empty elements and remove trailing and leading white space. But apart from that it seems to be working fine.
Never the less the solution is really good idea but for the moment it does not work with my current problem.
Thank you for your time and effort though.
Seeking for Perl wisdom...on the process of learning...not there...yet!
|