Another Search and replacement suggestion, wich is more versatile than my first suggestion:
Search pattern: (?P<Normal>Word)|(?P<Lower>word)|((?P<Upper1st>W)(?P<UpperRest>ORD)) Replacement pattern: \P<Normal>\u\P<Lower>\P<Upper1st>\L\P<UpperRest> As I said, play around with it in the Pattern Playground, you can learn a lot about BBEdits regex search capabilities. It's a mighty tool. EuliX Ulrich Kapp schrieb am Mittwoch, 28. Februar 2024 um 22:50:21 UTC+1: > I don't know if I understood your intention correctly, but maybe this ist > what you are looking for: > > *First switch of case sensitive searching!* > > Search pattern: > > (w)(ord) > > > Replacement pattern: > > \u\1\L\2 > > > With this, every *word *|*Word *|*WORD* turns into *Word.* > > > Use the "Pattern Playground" to play around with it. > > Hope it helps. > > Cheers! > Ulrich > > Jim Straus schrieb am Mittwoch, 28. Februar 2024 um 18:38:23 UTC+1: > >> Hello all regex experts - >> I'm looking to change a word in my code to another one, but it is >> sometimes "Word", "word" or "WORD". I can do this with three search and >> replaces. I also know about the \u\U modifications to the group (so \u\1 >> to uppercase the first letter), but that doesn't really work, since I'm >> changing the word (not using the group). What I think I want is something >> that would take just the case of the matched group and apply that to >> replacement text. Or is there another way to accomplish this in one >> pattern? >> Thanks! >> -Jim Straus >> > -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/b917ea38-f92b-47af-8f1a-f68d5e06547fn%40googlegroups.com.
