[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] regex to lift Crypt::Tea strings out of XML



Looking at the source of Crypt/Tea.pm, it appears your possible chars are
 
   [A-Za-z0-9\-_]
 
So you could "do one or more of any of those":
 
   my ($encrypted) = ($row =~ /attr_key="([A-Za-z0-9\-_]+)"/);
 
or "one or more anything that is not a quote":
 
   my ($encrypted) = ($row =~ /attr_key="([^"]+)"/);
 
or "one or more anything, non-greedy":
 
   my ($encrypted) = ($row =~ /attr_key="(.+?)"/);
 
?  untested...
 
 
---
 
reverse() is neat. I didn't know/remember that Perl function.  :)
 
my %a2b = (
        A=>000, B=>001, C=>002, D=>003, E=>004, F=>005, G=>006, H=>007,
        I=>010, J=>011, K=>012, L=>013, M=>014, N=>015, O=>016, P=>017,
        Q=>020, R=>021, S=>022, T=>023, U=>024, V=>025, W=>026, X=>027,
        Y=>030, Z=>031, a=>032, b=>033, c=>034, d=>035, e=>036, f=>037,
        g=>040, h=>041, i=>042, j=>043, k=>044, l=>045, m=>046, n=>047,
        o=>050, p=>051, q=>052, r=>053, s=>054, t=>055, u=>056, v=>057,
        w=>060, x=>061, y=>062, z=>063, '0'=>064,  '1'=>065, '2'=>066, '3'=>067,
        '4'=>070,'5'=>071,'6'=>072,'7'=>073,'8'=>074,'9'=>075,'-'=>076,'_'=>077,
);
my %b2a = reverse %a2b;
------
 
HTH,
 
j