comparison base/src/java/lang/String.d @ 118:ff7053751d15

Added Phobos implementation of java.lang.String.indexOf and lastIndexOf.
author Jacob Carlborg <doob@me.com>
date Sun, 17 Apr 2011 17:57:11 +0200
parents c81e3dc6b9ad
children d00e8db0a568
comparison
equal deleted inserted replaced
117:c81e3dc6b9ad 118:ff7053751d15
543 version(Tango){ 543 version(Tango){
544 int res = tango.text.Util.locatePattern( str, ch, start ); 544 int res = tango.text.Util.locatePattern( str, ch, start );
545 if( res is str.length ) res = -1; 545 if( res is str.length ) res = -1;
546 return res; 546 return res;
547 } else { // Phobos 547 } else { // Phobos
548 implMissing( __FILE__, __LINE__ ); 548 return std.string.indexOf(str[start .. $], ch);
549 return 0;
550 } 549 }
551 } 550 }
552 551
553 /// Extension to String 552 /// Extension to String
554 public int lastIndexOf(CString str, char ch){ 553 public int lastIndexOf(CString str, char ch){
560 version(Tango){ 559 version(Tango){
561 int res = tango.text.Util.locatePrior( str, ch, formIndex ); 560 int res = tango.text.Util.locatePrior( str, ch, formIndex );
562 if( res is str.length ) res = -1; 561 if( res is str.length ) res = -1;
563 return res; 562 return res;
564 } else { // Phobos 563 } else { // Phobos
565 implMissing( __FILE__, __LINE__ ); 564 return std.string.lastIndexOf(str[0 .. fromIndex], ch);
566 return 0;
567 } 565 }
568 } 566 }
569 567
570 /// Extension to String 568 /// Extension to String
571 public int lastIndexOf(CString str, String ch ){ 569 public int lastIndexOf(CString str, String ch ){