the editor is showing an error for that line

Changing "#^(%[[:xdigit:]]{2}|.){{$len}}#" By "#^(%[[:xdigit:]]{2}|.){{".$len."}}#"