@

■ 事例

 ↑ TOP

$ jython
Jython 2.5.0 (Release_2_5_0:6476, Jun 16 2009, 13:33:26) 
[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_13
Type "help", "copyright", "credits" or "license" for more information.
>>> # ---------------------------------------- String
    
>>> >>> # ---------------------------------------- charAt >>> s = String("as happy as happy can be") >>> s.charAt(3) 'h' >>> >>> s.indexOf('h') 3 >>> s.indexOf("as") 0 >>> >>> s.lastIndexOf('h') 12 >>> s.lastIndexOf("as") 9 >>> >>> # ---------------------------------------- length >>> s = String("零壱弐参肆伍陸漆捌玖") >>> s.length() 30 >>> >>> s = String("零壱弐参肆伍陸漆捌玖", "UTF-8") >>> s.length() 10 >>> >>> s = String("𩷛𩸽𩹉", "UTF-8") >>> s.length() 6 >>> >>> s.codePointCount(0, s.length()) 3 >>> >>> # ---------------------------------------- replace >>> s = String("as happy as happy can be") >>> s.replace('h','H') u'as Happy as Happy can be' >>> s.replaceAll("h[a-z]*y","HAPPY") u'as HAPPY as HAPPY can be' >>> s.replaceFirst("h[a-z]*y","HAPPY") u'as HAPPY as happy can be' >>> [>> from java.lang import String

 ↑ TOP