uneMule Posted June 29, 2021 Share Posted June 29, 2021 Bonjour à tous, une petite questions concernant l'utilisation des noms de groupes. La recherche fonctionne mais le remplacer renvoi le nom du groupe à la place de la valeur trouvée. Sinon $1:$3 fonctionnement. Hello everyone, I have a small question about the use of named groups. The search works but replacing it returns the group name instead of the value found. Else $1:$3 work. find : \<(?<hour>[0-1]?[0-9]|2?[0-3])\s?[hH]\s?((?<min>[0-5][0-9])\s?(′|min|mn)?)\> replace : ${hour} : ${min} Publisher 1.10.0.1098 et 1.9.2.1035 Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
Old Bruce Posted June 29, 2021 Share Posted June 29, 2021 Off the top of my head I am not sure if named groups is supported in the regular expressions for Publisher. I should also point out that I have never used them after learning how ... (years?) ... way back when. Quote Mac Pro (Late 2013) Mac OS 12.7.4 Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that. Link to comment Share on other sites More sharing options...
uneMule Posted June 29, 2021 Author Share Posted June 29, 2021 1 minute ago, Old Bruce said: Off the top of my head I am not sure if named groups is supported in the regular expressions for Publisher. Good evening. Me to. I'm not sure. But the regex does not create errors. It's amazing. Is that half supported? Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
walt.farrell Posted June 29, 2021 Share Posted June 29, 2021 43 minutes ago, uneMule said: Hello everyone, I have a small question about the use of named groups. The search works but replacing it returns the group name instead of the value found. Else $1:$3 work. find : \<(?<hour>[0-1]?[0-9]|2?[0-3])\s?[hH]\s?((?<min>[0-5][0-9])\s?(′|min|mn)?)\> replace : ${hour} : ${min} Publisher uses the boost.org regular-expression library, and you can find documentation on that at https://www.boost.org/doc/libs/1_76_0/libs/regex/doc/html/index.html or specifically https://www.boost.org/doc/libs/1_76_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html for the Perl-based regex syntax that (I think) Publisher uses. From that, I would conclude that to refer to a named backreference you need to use \g{name} or \k<name> but neither of those seems to work, either. uneMule 1 Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
uneMule Posted June 29, 2021 Author Share Posted June 29, 2021 33 minutes ago, walt.farrell said: From that, I would conclude that to refer to a named backreference you need to use \g{name} or \k<name> but neither of those seems to work, either. Bonsoir @walt.farrell, Yes, you are right. I tried that too $<hour> \<hour> g\{hour} Nothing to do. 33 minutes ago, walt.farrell said: specifically https://www.boost.org/doc/libs/1_76_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html Quote: Finally the \k escape can be used to refer to named subexpressions, for example \k<two> will match whatever matched the subexpression named "two" 33 minutes ago, walt.farrell said: or \k<name> but neither of those seems to work, either. you are right too. Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
walt.farrell Posted June 29, 2021 Share Posted June 29, 2021 After experimenting further, and reading the documentation more closely, I believe that the functions such as \g{name} and \k<name> are for use only while searching. They allow you to refer back to a prior match, so you can match the same thing again. They are not used during Replace processing in any application I have that supports regex processing. So, for Replace processing, we need to use the usual numbered forms, \1 or $1, \2 or $2, etc. Old Bruce 1 Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
uneMule Posted June 29, 2021 Author Share Posted June 29, 2021 2 minutes ago, walt.farrell said: After experimenting further, and reading the documentation more closely, I believe that the functions such as \g{name} and \k<name> are for use only while searching. They allow you to refer back to a prior match, so you can match the same thing again. I'll dig that. Thanks. Again. Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
walt.farrell Posted June 29, 2021 Share Posted June 29, 2021 You're welcome. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
uneMule Posted June 29, 2021 Author Share Posted June 29, 2021 @walt.farrell Effectivement cela permet de faire de la récursivité indépendamment du rang. (?'hour'\d)(\d{2})\g{hour} trouve 4784 2132. (?'lettre'\l)\g{lettre} trouve mm cc ll... Ça peut servir. Indeed, this allows for recursivity regardless of rank. (?'hour'\d)(\d{2})\g{hour} find 4784 2132. (?'lettre'\l)\g{lettre} find mm cc ll... This can be useful. walt.farrell 1 Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
walt.farrell Posted July 3, 2021 Share Posted July 3, 2021 With more research, this will work in Publisher: Find: (?<HOUR>[0-1]?[0-9]|2?[0-3])\s?[hH]\s?(?<MIN>[0-5][0-9])\s?(′|min|mn)? Replace: $+{HOUR}:$+{MIN} We were missing the + before. Also, it works only with $ and will not work if you use \ to refer to the replacement variables. uneMule and lacerto 2 Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
uneMule Posted July 4, 2021 Author Share Posted July 4, 2021 hi @walt.farrell thanks. I hadn't found this information. However, I looked for... Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
lacerto Posted July 4, 2021 Share Posted July 4, 2021 (...) Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted July 4, 2021 Share Posted July 4, 2021 1 hour ago, Lagarto said: I tried to use RegexBuddy to resolve this but it seems this app is mainly useful when there is already a working syntax (in some dialect) I found the info at http://www.regular-expressions.info/ but it should also be available in RegexBuddy in the documentation available in the Help. The documentation lists how things are handled in various RegEx interpreters, and you can just look at the column for Boost to see if something is supported there. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
lacerto Posted July 4, 2021 Share Posted July 4, 2021 (...) Quote Link to comment Share on other sites More sharing options...
uneMule Posted July 4, 2021 Author Share Posted July 4, 2021 3 hours ago, Lagarto said: InDesign users e.g. are spoilt by an in-built expression builder and saving feature so that shared complex searches can be easily re-used Yes, it is clear. Soon in Publisher? @walt.farrell Thanks again. You amaze me. walt.farrell 1 Quote Toujours pas !Windows 10 Pro 21H2 - Intel Core i7-3630QM CPU @ 2.40GHz - 16 Gb Ram - GeForce GT 650M - Intel HD 4000 Affinity Photo | Affinity Designer | Affinity Publisher | 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.