I am using a regex to substitute dates appearing in strings to superscript.
The standard format of the strings is a name followed by a period and a date.
ie.
John Smith.1967
Joe Doe.1945
Alan Evans.1943
This works fine although I am sure some of you guys can achieve the same results with a one liner.
The problem I have is that when line 5 converts a date, if the same date exists in the string, without the period, that is converted too.
I maybe missing something but the routine does not appear to be converting $DotDate (ie .1950) but just 1950.
I wish I had used a colon instead of a period but I am sure there is a solution to this.
Any help greatly appreciated
Keith
The standard format of the strings is a name followed by a period and a date.
ie.
John Smith.1967
Joe Doe.1945
Alan Evans.1943
This works fine although I am sure some of you guys can achieve the same results with a one liner.
Code:
1> if(($Valid == 0) && ($results[$x] =~ m/\.1/)){
2> for($k=1800; $k<2030; ++$k){
3> $DotDate=".$k";
4> if($results[$x] =~ m/\.$k/){
5> $results[$x] =~ s/$DotDate/<sup>($k)<\/sup>/g;
6> }
7> }
8> }
The problem I have is that when line 5 converts a date, if the same date exists in the string, without the period, that is converted too.
I maybe missing something but the routine does not appear to be converting $DotDate (ie .1950) but just 1950.
I wish I had used a colon instead of a period but I am sure there is a solution to this.
Any help greatly appreciated
Keith