Jump to content
You must now use your email address to sign in [click for more info] ×

Search for any uppercase or lowercase character


Laganama

Recommended Posts

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.

Affinity Suite 2.3.1 | iMac 5K (2017) 24GB, macOS Monterey 12.6.9

Link to comment
Share on other sites

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}|?

 

-- 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

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 ? (\?).

Affinity Suite 2.3.1 | iMac 5K (2017) 24GB, macOS Monterey 12.6.9

Link to comment
Share on other sites

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.

 

-- 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

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.

Link to comment
Share on other sites

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.

Affinity Suite 2.3.1 | iMac 5K (2017) 24GB, macOS Monterey 12.6.9

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.