Consulting

Results 1 to 4 of 4

Thread: Using wildcards - changing a part of sentence

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Posts
    58
    Location

    Using wildcards - changing a part of sentence

    Hi,
    I'm using Find And Replace with matching wildcards and following text to be found:


    \<Lead\>\{Lead:lead_red\}<*>, \{\/Lead:lead_red\}\{Body:red\}<*>► \{\/Body:red\}

    Searching works correct But I want repleace only a part of searched sentence:


    <Lead>{Lead:lead_red}<*>, <*>► {/Lead:lead_red}

    In this case "<*>" words with brackets<> should stay unchanged.
    E.g.
    Find:
    <Lead>{Lead:lead_red}KAMIONKA, {/Lead:lead_red}{Body:red}OCIEKA► {/Body:red}
    expectetion:
    <Lead>{Lead:lead_red}KAMIONKA, OCIEKA► {/Lead:lead_red}
    Thanks for helping


    Karol
    Karol

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You could use a wildcard Find/Replace with:
    Find = (\<*\{[!\{]@)(\{*\})\{*\}([!\{]@)\{*\}
    Replace = \1\3\2
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Posts
    58
    Location
    Many thanks for it, but this solution has little bug: When I'm putting cursor after searched text it cuts one of two words e.g.:


    Before:
    <Lead>{Lead:lead_red}KAMIONKA, {/Lead:lead_red}{Body:red}OCIEKA► {/Body:red}
    After:
    <Lead>{Lead:lead_red}KAMIONKA, {/Lead:lead_red}


    When I'm putting cursor before searched text everything works fine.

    Karol

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    That's a fairly common limitation of Find/Replace and has nothing to do with the Find/Replace expression I posted, as such.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •