Perl regular expression issue

file 1 contains:

<td><font ><strong>Type :</strong></font>
                              
                                    <A href="index.cfm?fuseaction=display&Instance=2&ssrid=x37103cc4cf651faff651427678f197d7"><font>Extension1</font></a>

                              
                           </td>

File 2 contains:

<td><font><b>Type:</b></font>
                  
                        
                        <A href="index.cfm?fuseaction=display&Instance=2&ssrid=xb3ac14a5bfa034397ebcdbdd043ad05b"><font size='3'>SimpleIdentificationInformation</font></a>

                        
                  
                  &nbsp;</td>
                  

I need to retrieve the Type value "Extension1" and "SimpleIdentificationInformation" from both files. I want just one regular expression. I wrote this one but doesn't return the data right.

$content2 =~ /Type.*\<font.+?\>(.*)\<\/font\>\<\/a\>/s){
saibskAsked:
Who is Participating?
 
hernst42Commented:
Hm works perfect with the data you gave:

(soory for the noob perl code)

open TEST1, "<page1.txt";
$content1 = "";
while (<TEST1>) {
        $content1 .= $_;
}
close TEST1;
 
open TEST2, "<page2.txt";
$content2 = "";
while (<TEST2>) {
        $content2 .= $_;
}
close TEST2;
 
$content1 =~ /Type.*\<font[^\>]*\>(.*)\<\/font\>\<\/a\>/s;
print $1;
print "\n";
$content2 =~ /Type.*\<font[^\>]*\>(.*)\<\/font\>\<\/a\>/s;
print $1;
print "\n";

Open in new window

0
 
hernst42Commented:
You could try as regular expression (untested):

/Type.*\<font[^>]*\>(.*)\<\/font\>\<\/a\>/s
0
 
saibskAuthor Commented:
nope doesn't work
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.