in reply to Re^4: Reliable way to detect base64 encoded strings
in thread Reliable way to detect base64 encoded strings

You have the right idea, but

if (...) $&Log ("it found base64-$i");
is not valid Perl. You want
if($string_whole =~ m/ ^ (?: [A-Za-z0-9+/]{4} )* (?: [A-Za-z0-9+/]{2} [AEIMQUYcgkosw048] = | [A-Za-z0-9+/] [AQgw] == )? \z /x) { Log("$string_whole is valid base64"); }

Replies are listed 'Best First'.
Re^6: Reliable way to detect base64 encoded strings
by hahngoldn (Initiate) on Apr 16, 2010 at 22:49 UTC
    when I use it as you have it I get
    Unmatched [ in regex; marked by <-- HERE in m/ ^ (?: [ <-- HERE A-Za-z0-9+/ at C:\aaa\aeh_pop.pl line 153.
    I thought I was getting a problem with the regex...not the IF....but I didn't copy this in because i figured it was something I was doing. I see matched brackets... I tried to pull up into one line thinking the white space was giving issues...that didn't help. Thanks.
      Oops, mine wasn't valid Perl either! I used an unescape "/" in the pattern. Two solutions: escape it, or change the delimiter. I corrected the original post.
        None of the above code works for me?? I have been trying different regex's to find Base64's on webpages and then decrypt them. The above code doesnt even look like perl..more like php?? Is it a cgi code or something because ive yet to see perl in that type of format?? I know very little cgi at the moment. Im making my way through all the perl modules now and trying them out in scripts