Would your word always appear immediately after a dot or @ when you don't want it to match? You can use a negative look-behind for that: (?<![@.])<your word here>
Thank you both. It wouldn't always appear after a dot or an @, so SRiegel's solution works, except…
I forgot to mention in my original question, I would need to find Adobe, Adobe's and Adobes.
This seems to work:
(?<= |\r|\n)Adobe’?s?(?= |[[:punct:]])
How could I change the string above to search for any combination of upper and lower case versions of Adobe (adobe / ADOBE)?
Simply a grep style:
I know! it's a joke!
[posted without having seen keefomatic's post!]
Even more simple is to turn case-insensitive On for a shorter version (?i)(?<![.@])adobe
The winner is … still me for less than 1 minute! Aha! Thanks Jean-Claude!
Thanks to everyone for their help - I'm learning slowly!
I have nurtured my search to this:
which finds almost everything. I just need to add a negative look ahead which finds any letter except s (lower case 's')
This would distinguish between finding Adobe's or Adobes, but not finding adobehelp@…
You don't need the or (|) in the look behind. Put it all in the class: (?<![@.\l\u])
But this should be finding the word when preceded by whitespace or any punctuation other than @ or a period. Is that what you want? If you can really define the conditions under which you DO want a match it might be easier to design an expression that won't give you false matches.
For the look-ahead, do you really mean LETTER other than s, or do you mean CHARACTER other than s? The latter can be done with a positive lookahead and the negative class [^s] or [^sS] if you want to rule out both upper and lowercase s.
Thanks Peter. I've fixed the negative lookbehind, but I can't work out how to add the Positive lookahead you mentioned.
Here's a shot of what I'm trying to achieve. In the example, everything in blue has been changed by the search. I want the final blue change (email@example.com) left unchanged.
For fun, can you send us the text of the first text block (selected) to make a test! Thanks.
OK, it looks to me like you want it find whole words, or beginnings of words that end in upper or lowercase s or up to an apostrophe. You can use the look-ahead (?=[.,'\ssS]) to stop the match at whitespace, period, comma, apostrophe, or any type of s, but it's going to fail on adobe.com if you want to find Adobe. at the end of a sentence. Looks to me, though, like you can remove the period from the class and use it in a second expression as part of an "or" like this (\<(?i)adobe(?=\.\s))|(\<(?i)adobe(?=[,'\ssS])) so that it will match adobe before a period-whitespace (end of sentence), but not period-any other character (url).
Still hard to shot the apple on the head… with, in addition, a single bullet!
Maybe a grep style:
Char style: including 'All in capitals'.
To be tested!
I tried the "or" combination (took me quite awhile to get it to find all the cases correctly, if I understood what was wanted) before I posted, and it seemed to be able to produce Keefomatics, desired result according to post 11.
Be careful! We obtain the same result! Cool!
… But, for you, the case: "(Adobe)" doesn't work.
Maybe, at last, some cases too (to be found)!
He didn't seem to want to find (Adobe), but I don't think that would be hard to add.
My expression is designed to find only cases where adobe starts the word and only if the word stands alone, is plural, or is possessive, since that was what the example shows.
it is not related to the problem here, but I see that you are working with a German Paragraph language, as your "Hochkomma"(’) looks like a German closing apostrophe (‘). This is caused to a problem in the dictionary settings in German. Only to remember to take care on this and push some improvement requests to Adobe.
Just to explain further, the reason I'm trying to do this is that my client's company name (not Adobe) gets supplied to me in any number or ways, but is meant to be set in ALL CAPS, including an accented character. That's why I'm trying to achieve ADOBE's and not ADOBE'S, and why I don't want to select any occurances where the word appears in a web address or email address, as they would remain unchanged..
As requested, just for fun, here's the text block:
adobe Adobe ADOBE adobe, Adobe, ADOBE, adobe. Adobe. ADOBE.
Post 14 - we have a winner - thanks to Peter and everyone else who has helped.
Ah, simultaneous typing...