Find&Replace.....solution needed ASAP...Thanks

Hi All,

I am facing the following issue and cant find a solution to it.

I have a rich text field on a document containing text data. This field basically has html written with PassThruHTML. There are around 50,000 such documents.

This is what i have to do…

i have to perform a find & replace. But in this case i have to form the search string to be replaced. I have to search for all the “<a href="mailto=rishi.arora@abc.com” " tags and replace it with <a href=“javascript:void()” functionname('rishi arora)>".

I extract the name of the person before the @ symbol and pass it as an argument to the function.

I have written the code using FindFirstString & FindNextString and am able to replace. But if some of the part in the text is formatted i.e bold it does not return that part.

eg: "<a href=“mailto=rishi.arora@abc.com>Mail Me”…i am able to find this and replace with the required text but if "@abc.com is bold…in the resulting string i get only "<a href=“mailto=rishi.arora” instead of the entire string “<a href="mailto=rishi.arora@abc.com>”.

even if the text before the @symbol is in arial font and after that is in verdana…i cant get the entire string…

i deally the formatting should not make a difference…it should simply find & compare and replace the text…

I also tried using Midas LSX but same result.

I hope i am able to explain it clearly…i need a solution…though this is a one time activity…it is not possible to replace manually in 50,00 docs…

Thank You…

Rishi Arora.

Subject: Find&Replace…solution needed ASAP…Thanks…

If different parts of the text are formatted differently, they do not belong to the same text run. It’s as simple as that. If you can’t kill the formatting (making the text in each para all one run – Midas should probably be able to do that), then you need to make your search and destroy code a lot more intelligent. DXL could probably handle it easily enough (well, relatively speaking, of course – coaxing all of the text nodes out of a set of nested element nodes takes a bit of coding whether you are using DOM or SAX).

Subject: RE: Find&Replace…solution needed ASAP…Thanks…

i think stan you have understood the issue here.

It is not that there is a bold tag but some part of the text is highlighted as bold. That might be the reason i dont get the entire sting, as you said it does not belong to the same text run.

Though now i need to figure out how to use DXL or Midas LSX in this context…

coz actually there are seven such rich text fields in the document and each field could have none, one or more of such tags. i need to replace every mailto tags.

it could be in the following way…

Mail Me

…even if there is a break in the complete tag i have to locate it and replace with the required tag.

how is the the limits of the paragraph defined in the Rich text field…how does it defines the start and end of a paragraph…

Subject: No solution offered - Just some info.

This sounds to me as if your documents contain broken HTML. What you’re describing is:<a href="mailto=rishi.arora@abc.com>Mail Me

And to my knowledge, this is not valid.

You should more likely see

<a href="mailto=rishi.arora@abc.com>Mail Me

or

<a href="mailto=rishi.arora@abc.com>Mail Me

Now, how you fix this? well, I’m not very good at programs that parse text, but I’d bet there are some people reading who are.

Subject: RE: No solution offered - Just some info.

I think the formatting in question is Rich Text formatting, which isn’t translated to HTML when the text is marked as passthru. It DOES, however, affect the CD record structure of the text, so different parts of the HTML would live in different text runs, and won’t be seen as contiguous text.

Subject: RE: No solution offered - Just some info.

i think stan you have understood the issue here.

It is not that there is a bold tag but some part of the text is highlighted as bold. That might be the reason i dont get the entire sting, as you said it does not belong to the same text run.

Though now i need to figure out how to use DXL or Midas LSX in this context…

coz actually there are seven such rich text fields in the document and each field could have none, one or more of such tags. i need to replace every mailto tags.

it could be in the following way…

Mail Me

…even if there is a break in the complete tag i have to locate it and replace with the required tag.

how is the the limits of the paragraph defined in the Rich text field…how does it defines the start and end of a paragraph…

Subject: Find&Replace…solution needed ASAP…Thanks…

With Midas in this case, you could handle this a couple of ways. You could cycle through the paragraphs, searching for the string using the GeniiRTChunk.UnformattedText property, which returns all the text in the chunk (in this case a paragraph). Another alternative is to reset all the text attributes and consolidate the text that way. You say that you have tried Midas, so you presumably have a license. Could you send at e-mail to support (at) geniisoft.com describing the situation a bit, and I am sure we will send back a sample showing you how to accomplish it. That is something we do for customers or potential customers all the time.

Subject: RE: Find&Replace…solution needed ASAP…Thanks…

Thanks for following this up, Ben. I knew that Midas would be able to do it, but not how (syntactically). In this case, since the text is all passthru, dropping the formatting inside the paragraphs and consolidating the runs would seem to be the most reasonable way to do it.

Subject: Option Compare

What happens if you set Option Compare to NoCase and NoPitch and set all the FindFirstString and FindNextString options to False?

Subject: RE: Option Compare

Hi Lawrence…

i already tried doing that…no luck…

the function i wrote is the following…

Function StampNewVal(rtitem As NotesRichTextItem, doc As NotesDocument)

searchstring$ = “<A HREF=”“MAILTO:”

searchstring1$ = “”

Set rtnav = rtitem.CreateNavigator

Set rtrange = rtitem.CreateRange

Do

If rtnav.FindFirstString(searchstring$,RT_FIND_ACCENTINSENSITIVE+RT_FIND_CASEINSENSITIVE+RT_FIND_PITCHINSENSITIVE) Then

Call rtrange.SetBegin(rtnav)

'Msgbox rtrange.TextRun,“set text range”

Call rtnav.FindNextString(searchstring1$,RT_FIND_ACCENTINSENSITIVE+RT_FIND_CASEINSENSITIVE+RT_FIND_PITCHINSENSITIVE)

Call rtrange.SetEnd(rtnav)

'Msgbox rtrange.TextRun,“end range”

a$ = rtrange.TextRun & “”

'Msgbox a$,“a$”

If Instr(1,a$,“?”,5) Then

b$ = Trim(Replace(Strleftback(Strleftback(Strrightback(a$,“:”),“?”),“@”),“.”," "))

Else

b$ = Trim(Replace(Strleftback(Strrightback(a$,“:”),“@”),“.”," "))

End If

'Msgbox b$,“b$”

If b$ = “” Then

Call WriteToFile(doc)

Exit Function

End If

'Msgbox Strleftback(a$,“</”)

'Msgbox Strrightback(Strleftback(a$,“</”),“”“>”)

c$ = “<A HREF=”“javascript:void(0)”" onclick=““contactUs('” + b$ + “')””> " + Trim(Strrightback(Strleftback(a$,“</”),“”“>”)) + “”

'Msgbox c$,“c$”

Set rtnav = rtitem.CreateNavigator

Set rtrange = rtitem.CreateRange

Call rtrange.FindAndReplace (a$,c$,RT_FIND_ACCENTINSENSITIVE+RT_FIND_CASEINSENSITIVE+RT_FIND_PITCHINSENSITIVE)

Else

Exit Do

End If

Loop

Call rtitem.Compact

'Call doc.save (True,False)

End Function