Replace word in string

วันจันทร์ที่ 14 กันยายน พ.ศ. 2552

Replace the word is used in conjunction with a cut that is cut out words in the desired location. Then replace the string you want.

substr (string variable, as the starting cut, the number you want) = "string you want to go instead."

Eg.

$ a = "Welcome to Java! \ n";

substr ($ a, 11, 4) = "Perl";

# This means that the cut out words from position 11 to number 4 is out there to replace the word Java and Perl enter Therefore $ a = "Welcome to Perl! \ N".

substr ($ a, 7, 3) = "";

# This means that the cut out words from position 7 to 3 the number is out there "to" and replace with the word "go hence $ a =" Welcome Perl! \ N ".

substr ($ a, 0, 0) = "Hello,";

# This means that the cut out words from position 0 to 0 a That is not cut out any words out. Then replace the string "Hello," Therefore $ a = "Hello, Welcome Perl! \ N".

0 ความคิดเห็น:

แสดงความคิดเห็น

 
 
 
 
Copyright © Basic Perl