Variable length expressions in the lookahead are OK, but you only really need to find the first digit, so you can eliminate the + after \d and that will also work. The \S+ is a problem, though. Besides being too general (in my opinion), you can't have variable lengths in the look-behind, so you need to figure out what it is you really want to match. Are you looking for the literal "word" or is that a stand-in for any word? Are you matching particular words?
Thanks for quick response Peter,
Yes I am looking for particular words, so I guess I have to find any combination of the ending (when let's say any language has different combination of endings). Otherwise I could go ahead with (?<=\w+)\s(?=\d) but the problem is I cannot keep any words with digits together (intention of the GREP is to replacing that space into non-breaking one) as they may be part of next word. I think the only solution would be something like
change to: no-break char style
You can't use \w+ in the lookbehind and I'm not all that sure that you really want to apply No Break to the entire word before the space (do you?), which means you may not be able to do this as a GREP style.
It would help if you gave us some real examples of the various combinations that you want to match, and any that should not match.
By the way, I think \<WORD[\w\d]+\s\d might be closer to what you have in mind. The \S+ would match all alphanumerics and punctuation.
Would like to thank you to all your answers guys. I found satisfactory result in:
find what: (\<WORD\S+)(\s)(?=\d)
change to: $1~s
Thanks once again!
1 person found this helpful
Peter Stnsz wrote:
… find what: (\<WORD\S+)(\s)(?=\d)
change to: $1~s
Your Grep do not find your first example: WORD 0,2 (WORD without any ending)
And you don't need the second ()
And please do not use \S
Use this instead:
(l is the little L)