파일의 일부 정보를 구문 분석하려고합니다. 파일의패턴 매칭 perl
정보 :
$name = @_; # This @_ has all the information from the file that I have shown above.
#For matching pattern Rita_bike_house_Sha9
($a, $b) = $name =~ /\w\d+/;
if ($a ne "" and $b ne "") { return ($a,$b) }
# this statement doesnot work at all as its first condition
# before the end is not satisified.
인가 :
Rita_bike_house_Sha9
Rita_bike_house
가 나는 아래의 코드를 사용하는 것을 위해 DIS
$a = Rita_bike_house and $b = Sha9,
$a = Rita_bike_house and $b = "original"
같은 출력을 얻을 갖고 싶어 거기에 $a
에 "Rita_bike_house"를 저장하고 "Sha9"를 $b
에 저장할 수있는 방법이 있습니까? 내 regexp 뭔가가없는 것 같아요. 아무것도 제안 할 수 있니?
'$ 이름 = @ _'는 코드 냄새입니다. 아마 당신은 ['($ name) = @ _'] (http://stackoverflow.com/q/10031455/168657)을 의미 할 것입니다. – mob
'\ w'는'_' (밑줄)과도 일치하므로보다 정확한 일치 규칙이 필요합니다. – jm666
죄송합니다. 예, 그것은 ($ name) = @_; – user2498830