Results 1 to 12 of 12
  1. #1
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post

    WildCard Regex - Highlight Between 2 Placeholders

    Folks,


    good Sunday to all.

    I thought this would not be too hard to do but have got stuck again

    Wildcards / Regex is not my forte

    How do I isolate the string between the 2 red placeholders


    BEG highlightthistext ()



    Wildcard / RegEx

    BEG * ([^0-9<>]+)


    going a bit loopy now - with all the combos tried

    thanks ever so much

    pb

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Find = BEG[!\)]@\)
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post
    Hi Paul,

    thanks for helping.

    I am testing it in word. so i put it in the find box with the wildcards on,

    Sadly its not finding the search

    Am I not searching for it correctly?

    cheers

    pb

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    It works for me with your example and wildcards 'on'. Do note that, if you specify a colour, all of the range to be found must have that colour. In your example, only some of the content is coloured.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post
    Hi Paul,

    good day to you.

    image 2.png



    it's working for you so i should get the same result

    No results found. I tried to fiddle about with it -but I'm not sure why its playing up

    pb

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    The only thing I can think of is that you have a space or something such after the Find expression (which, of course, no-one else could see).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post
    Hi Paul,

    ahh the joys of programming, so unforgiving one space is too much for it

    The space was the problem - how did you know

    Now on to last thing

    It highlighted the whole string

    I only wanted the text inbetween BEG and ()

    BEG HighlightOnlyME ()

    I will fiddle about and see if I can work it out - if in the mean time you beat me to it - please do post

    BEG[!\)]@\)

    BEG[!\(]@\) - did not work

    thanks

    pb

  8. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by pb89 View Post
    I only wanted the text inbetween BEG and ()

    BEG HighlightOnlyME ()
    Please explain. What happens with the BEG and ()?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  9. #9
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post
    Hi Paul,

    I simply wanted to highlight the text between

    BEG and ()

    So I could copy the string eventually or use it in a macro.

    BEG Extract_Me ()


    BEG Extractmetoo ()


    BEG AnotherStringfoundExtract ()

    and some more items where ever found.


    I apologise but regex - is a really hard skill for me, I do try but my brain goes upside down when I encounter it


    I hope its not to hard to understand what Im trying to highlight extract

    thanks for persevering - appreciated

    pb

  10. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Any highlighting or other formatting done via a Find/Replace, regardless of whether you're using wildcards, applies to the whole expression. Anything fancier would require a macro.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #11
    Star Lounger
    Join Date
    Jan 2016
    Posts
    77
    Thanks
    18
    Thanked 1 Time in 1 Post
    Thanks Paul,

    I found a way to not be too fussed about the placeholders - can just delete them - I know sometimes the obvious solution is too simple to work

    Have a great day

    pb

  12. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    If you don't want the placeholders, you could use a wildcard Find/Replace with:
    Find =BEG ([!\(\)]@)\(\)
    Replace = \1
    Cheers,

    Paul Edstein
    [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
  •