| 615 | } |
| 616 | |
| 617 | @StarlarkMethod( |
| 618 | name = "find", |
| 619 | doc = |
| 620 | "Returns the first index where <code>sub</code> is found, or -1 if no such index exists, " |
| 621 | + "optionally restricting to <code>[start:end]</code>, " |
| 622 | + "<code>start</code> being inclusive and <code>end</code> being exclusive.", |
| 623 | parameters = { |
| 624 | @Param(name = "self", doc = "This string."), |
| 625 | @Param(name = "sub", doc = "The substring to find."), |
| 626 | @Param( |
| 627 | name = "start", |
| 628 | allowedTypes = { |
| 629 | @ParamType(type = StarlarkInt.class), |
| 630 | @ParamType(type = NoneType.class), |
| 631 | }, |
| 632 | defaultValue = "0", |
| 633 | doc = "Restrict to search from this position."), |
| 634 | @Param( |
| 635 | name = "end", |
| 636 | allowedTypes = { |
| 637 | @ParamType(type = StarlarkInt.class), |
| 638 | @ParamType(type = NoneType.class), |
| 639 | }, |
| 640 | defaultValue = "None", |
| 641 | doc = "optional position before which to restrict to search.") |
| 642 | }) |
| 643 | public int find(String self, String sub, Object start, Object end) throws EvalException { |
| 644 | return stringFind(true, self, sub, start, end); |
| 645 | } |
| 646 | |
| 647 | @StarlarkMethod( |
| 648 | name = "rindex", |