Laganama Posted December 8, 2022 Share Posted December 8, 2022 Hi, I recently use this handy regex expression to locate any uppercase or lowercase character within the texts in Afpub documents: \p{Lu} \p{Ll} The probleme is, that this expression does not work, when I surround it with square brackets to combine it with some other expression. For example, if I want to search for any uppercase or, let`s say, question mark, this expression should, in my opinion, work: [\p{Lu}\?] Only, the result of this search is wrong and Publisher finds for me either the character "p", "L", "u", or the mentioned question mark. I`m not sure, if this is some kind of bug, an incompability or if I just write the expression the wrong way. Thanks. Quote Affinity Suite 2.5.4 | iMac 5K (2017) 24GB, macOS Monterey 12.7.6 Link to comment Share on other sites More sharing options...
walt.farrell Posted December 8, 2022 Share Posted December 8, 2022 29 minutes ago, Laganama said: For example, if I want to search for any uppercase or, let`s say, question mark, this expression should, in my opinion, work: Sorry, but no. That's not valid reg-ex syntax for what you want. For any upper-case or a ? it would just be \p{Lu}|? Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. Laptop 2: Windows 11 Pro 24H2, 16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU iPad: iPad Pro M1, 12.9": iPadOS 18.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1 Link to comment Share on other sites More sharing options...
Laganama Posted December 8, 2022 Author Share Posted December 8, 2022 When I test it here it works well: https://regex101.com/ Therefore I think it should work in Afpub too. The use of square brackets has its meaning. A vertical slash alternates the entire string before it from the one after it. I can use square brackets to define exactly what group of characters I need to alternate. I know I can use regular brackets in combination with the vertical slash to border the "or" conditon, but still I guess those squared brackets could work too. 59 minutes ago, walt.farrell said: \p{Lu}|? For the question mark you have to use also the back slash before the ? (\?). Quote Affinity Suite 2.5.4 | iMac 5K (2017) 24GB, macOS Monterey 12.7.6 Link to comment Share on other sites More sharing options...
walt.farrell Posted December 8, 2022 Share Posted December 8, 2022 17 minutes ago, Laganama said: For the question mark you have to use also the back slash before the ? (\?). Thanks. 17 minutes ago, Laganama said: When I test it here it works well: https://regex101.com/ Therefore I think it should work in Afpub too. There are many regular expression versions, and many small differences between them. But thanks for pointing out the difference between yours and mine. Publisher uses the Boost regular expression processor. Here's the doc for the current (1.80) release of Boost. I'm not sure what level of Boost library Publisher includes, nor exactly what version of the reg-ex processor they're using among the several versions that Boost supports: https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/index.html According to RegEx Buddy your form does not work with Boost, but it may depend on exactly how Publisher configures the reg-ex processing, which Serif has not documented. You can use \p{Lu} outside of the [], but not inside them, from my tests. And RegEx Buddy agrees, when configured to use Boost. Without more information from Serif on exactly what options they pass Boost, and which flavor or reg-ex they've told it to interpret, it's impossible for me to say more than that. Old Bruce 1 Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. Laptop 2: Windows 11 Pro 24H2, 16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU iPad: iPad Pro M1, 12.9": iPadOS 18.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1 Link to comment Share on other sites More sharing options...
garrettm30 Posted December 14, 2022 Share Posted December 14, 2022 In case you are looking for a workaround (and I recognize that maybe you are not), you can use [:upper:] and [:lower:] inside of character class brackets, and that will work with Publisher’s regex. One word of caution: if “Match case” is not checked, then both both expressions will match both upper and lower. Quote Link to comment Share on other sites More sharing options...
Laganama Posted December 14, 2022 Author Share Posted December 14, 2022 2 hours ago, garrettm30 said: In case you are looking for a workaround (and I recognize that maybe you are not), you can use [:upper:] and [:lower:] inside of character class brackets, and that will work with Publisher’s regex. One word of caution: if “Match case” is not checked, then both both expressions will match both upper and lower. Hi @garrettm30, thanks for the info. Indeed, I also found that [:upper:] and [:lower:] works as you write. And the simplest syntax works as well! \u and \l. I don't know why I didn't use these. It seems to me, that at some time these short variants didn't work in Afpub at all (maybe some bug at that time?) and I stopped using them. Instead of them I started to use mentioned \p{Ll} or [:lower:] But now I tried and they work well too. Quote Affinity Suite 2.5.4 | iMac 5K (2017) 24GB, macOS Monterey 12.7.6 Link to comment Share on other sites More sharing options...
garrettm30 Posted December 14, 2022 Share Posted December 14, 2022 29 minutes ago, Laganama said: And the simplest syntax works as well! \u and \l. Thanks for that. I tested that myself before I posted, and it did not work. It would seem I got tripped up by the “Match case” issue myself. Laganama 1 Quote 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.