I want to create a perl code to extract what is in the parentheses and port it to a variable -


i want create perl code extract in parentheses , port variable. "(05-nw)hplaserjet" should become "05-nw" this:

  • catch "("
  • take out spaces exsist in between ()
  • everything in between () = variable 1

how go doing this?

perldoc perlre

use warnings; use strict;   $s = '(05-nw)hplaserjet'; ($v) = $s =~ /\((.*)\)/; # grab between parens (including other parens) $v =~ s/\s//g; # remove whitespace print "$v\n";  __end__  05-nw 

see also: perl idioms explained - @ary = $str =~ m/(stuff)/g


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -