|
-
Nov 29th, 2004, 12:39 AM
#1
Thread Starter
Addicted Member
Recieving a string to search, then replace
I am creating a class called Editor that is able to perform a search/replace function on a document (a sentence or paragraph).
The Editor class includes two constructors:
• The first has no parameters
• The second has one parameter (the document to be searched)
The class includes a setDocument() and a getDocument() method.
The class includes two overloaded versions of a method called replace():
• The first has two parameters (search text, replacement text) and works on the current document.
• The second receives three parameters (the document to be searched, the search text, the replacement text).
• The replace method returns the new document as a String.
The replace method searches the document for instances of the search text, replaces that text with the replacement text.
Example:
document: “Rich is here”
search text: “is”
replacement text: “was”
result: “Rich was here”
What I need to know is how would I go about searching, then replacing the text in the string that I am searching?
Last edited by ddmeightball; Nov 29th, 2004 at 07:14 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|