• 1 reply
  • Latest Post - ‏2013-11-18T09:07:06Z by pommCannelle
6 Posts

Pinned topic Search for text and replace with bolded text

‏2013-11-17T14:27:06Z |

It seems like by this time (using DOORS 9.5)  there should be an option in the Search and Replace to apply rich text options features ... but that being said ...I am not a DXL coder or a coder of any kind and I need to search for a specific word in the Object Text attribute and then bold that text. 

I have read the Jan 11 2012 "Finding a rich text phrase and replacing it with different rich text" topic and cannot figure out how to do this. 

Does anyone have a simple dxl script with simple instuctions for how to implement that that would assist me in performing this task?

Thank you

  • pommCannelle
    125 Posts

    Re: Search for text and replace with bolded text


    Here after a simple example to do what you want ... Feel free to post your code if you are in trouble ;)

    string bold(string s, string wordToBold){
        string buf = s
        string res = ""
        Regexp r = regexp wordToBold
        int index = 0
        while ( !null buf && r buf ){
            res = res buf[0:start(0)-1] "{\\b{" wordToBold "}}"
            buf = buf[start(0)+length(wordToBold):]
            index += start(0)+length(wordToBold)
        res = res buf ""
        return res

    Object o = current
    o."object text" = richText bold ( o."object text""", "test" )

    Best regards !