in reply to Simple RegEx Substring Extraction from a Delimited Text Record

Hi ozboomer, Try this,

use strict; use warnings; my ($int) = (split "!(?:INT=)?", "SLOT3=4,4,2!INT=115!VC=4!CS=270!PK=/ +")[1]; print "Method 1 :\t\$int: $int\n"; my ($int1) = ("SLOT3=4,4,2!INT=115!VC=4!CS=270!PK=/")=~ m/\!INT=([^\!] ++)/; print "Method 2 :\t\$int: $int1\n";

Comparsion of above methods.

use strict; use warnings; use Benchmark 'cmpthese'; cmpthese(-1, { method1 => 'my ($int) = (split "!(?:INT=)?", "SLOT3=4,4,2!INT=11 +5!VC=4!CS=270!PK=/")[1]', method2 => 'my ($int) = ("SLOT3=4,4,2!INT=115!VC=4!CS=270!PK=/") +=~ m/\!INT=([^\!]+)/', }); __END__ Rate method1 method2 method1 133487/s -- -64% method2 366033/s 174% --

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';