2011-08-08 4 views

답변

2
$temp = " Hello world"; 
#print $temp; 
$temp =~ s/^\s+//; 
print $temp; 
6
my $foo = " \t\n\r hello, world!"; 
$foo =~ s/^\s+//; # This is the line that removes the leading whitespace. 
print "$foo\n"; 
print ord($foo) . "\n"; 

윌 표시 :

hello, world! 
104 

(104)는 문자열이 선두에 공백이 없다는 것을 증명 h에 대한 ASCII 문자 코드입니다.

5

이 아무것도 대체 문자열 (^)의 시작 부분에 반복되는 공백 (\s+)를 검색 (즉, 여기에 구분 기호 사이에 무엇 : //) :

$myString =~ s/^\s+//; 
관련 문제