We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Find string

Hi,

I want to find strings in a word document like <@......> and list them a popup control.How can I do this?

Forexample;

Our customer will put , following tags to our document.

<@Product Code>

<@Product Name>

Then will find all of them.After finding I will list them on a pop up control like Product Code,Product Name

It is very important for me.Colud you please reply?

Hi Ahmet,

Thanks for your query. Yes, you can achieve your requirement by implementing IReplacingCallback interface. Please use the same approach shared at following documentation link to find tags like <@Product Code> and <@Product Name>.
http://www.aspose.com/docs/display/wordsnet/How+to+Find+and+Highlight+Text

Please also read the following ariticle about 'Find and Replace' and check following code snippet for your kind refernece.
http://www.aspose.com/docs/display/wordsnet/Find+and+Replace+Overview


Document doc = new Document(MyDir + "in.docx");

DocumentBuilder builder = new DocumentBuilder(doc);

Regex regex = new Regex("\\<@", RegexOptions.IgnoreCase);

FindEval obj = new FindEval();

doc.Range.Replace(regex, obj, true);

foreach (Run run in obj.nodes)

{

Console.WriteLine(run.Text);

}

public class FindEval : IReplacingCallback

{

//Store Matched nodes

public ArrayList nodes = new ArrayList();

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)

{

// This is a Run node that contains either the beginning or the complete match.

Node currentNode = e.MatchNode;

nodes.Add(currentNode);

return ReplaceAction.Skip;

}

}


Hope this helps you. Please let us know if you have any more queries.


Ok.Thank you…