java.lang.Object
com.aspose.words.FindReplaceOptions
public class FindReplaceOptions
- extends java.lang.Object
Specifies options for find/replace operations.
Example:
Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello _CustomerName_,");
// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());
FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);
// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);
// Save the modified document.
doc.save(getArtifactsDir() + "Range.ReplaceSimple.docx");
FindReplaceOptions
public FindReplaceOptions()
-
FindReplaceOptions
public FindReplaceOptions(int direction)
- Parameters:
direction
- A FindReplaceDirection value.
FindReplaceOptions
public FindReplaceOptions(IReplacingCallback replacingCallback)
-
FindReplaceOptions
public FindReplaceOptions(int direction, IReplacingCallback replacingCallback)
- Parameters:
direction
- A FindReplaceDirection value.
Property Getters/Setters Detail |
getApplyFont | |
public Font getApplyFont()
|
-
Text formatting applied to new content.
-
Paragraph formatting applied to new content.
getDirection/setDirection | |
public int getDirection() / public void setDirection(int value)
|
-
Selects direction for replace. Default value is FindReplaceDirection.FORWARD.
The value of the property is FindReplaceDirection integer constant.
getFindWholeWordsOnly/setFindWholeWordsOnly | |
public boolean getFindWholeWordsOnly() / public void setFindWholeWordsOnly(boolean value)
|
-
True indicates the oldValue must be a standalone word.
Example:
Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello _CustomerName_,");
// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());
FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);
// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);
// Save the modified document.
doc.save(getArtifactsDir() + "Range.ReplaceSimple.docx");
getMatchCase/setMatchCase | |
public boolean getMatchCase() / public void setMatchCase(boolean value)
|
-
True indicates case-sensitive comparison, false indicates case-insensitive comparison.
Example:
Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello _CustomerName_,");
// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());
FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);
// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);
// Save the modified document.
doc.save(getArtifactsDir() + "Range.ReplaceSimple.docx");
getPreserveMetaCharacters/setPreserveMetaCharacters | |
public boolean getPreserveMetaCharacters() / public void setPreserveMetaCharacters(boolean value)
|
-
True indicates that meta-characters beginning with "&" are preserved.
Default value is false.
Example:
Shows how to preserved meta-characters that beginning with "&".
Document doc = new Document(getMyDir() + "Range.FindAndReplaceWithPreserveMetaCharacters.docx");
FindReplaceOptions options = new FindReplaceOptions();
options.setFindWholeWordsOnly(true);
options.setPreserveMetaCharacters(true);
doc.getRange().replace("sad", "“ some text ”", options);
-
The user-defined method which is called before every replace occurrence.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.