🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19567

Re: String.indexOf( string s)

#19567
From: Joe Nuxoll
Date: Fri, 23 Jan 1998 00:00
26 lines
1351 bytes
Kent Mestayer wrote:
> The built-in string class is noticably absent a method which attempts to
> find a sub-string. There's indexOf( int ch, int offset) which I could use to
> write my own solution, but this seems like a real elementary function which
> someone has written or is available elsewhere in JBuilder if I only knew
> where to look.
> What class do YOU use to find the location of a sub-string within another
> string?

I think you missed it:

In java.lang.String:

public String substring(int beginIndex)
public String substring(int beginIndex, int endIndex)
public int indexOf(String str)
public int indexOf(String str, int fromIndex)

For example:

String text = "Hello Kent Mestayer";
String justKent = text.substring(text.indexOf("K"), text.indexOf("M") -
2);

 - Joe Nuxoll
Technical Details
Message-ID: <34C8ED97.6BE84671@corp.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6aakl0$mri5@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,551e88b4e3e558be
X-Google-Attributes: gidf74b3,public
From: Joe Nuxoll <jnuxoll@corp.borland.com>
Subject: Re: String.indexOf( string s)
Date: 1998/01/23
Message-ID: <34C8ED97.6BE84671@corp.borland.com>
X-Deja-AN: 318678443
Content-Transfer-Encoding: 7bit
References: <6aakl0$mri5@forums.borland.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: Borland International, Inc.
Newsgroups: borland.public.jbuilder.java.language