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

Recommended Posts

18 minutes ago, fde101 said:

I'd rather have PCRE than GREP.  PCRE is a much richer language.

The request was for GREP as used in InDesign, which I believe uses PCRE (including in its JavaScript). Much more extended than the various flavors of ECMA, which lags far behind in capabilities. The main plus side to me for PCMA is there are a bazillion tutorials on the web and it's used everywhere and in most text editors and dedicated PCRE tools.

Link to comment
Share on other sites

Nowadays usually Perl Compatible Regular Expressions (PCRE) are more or less the defacto used standard here (at least among programming languages, better dev tools and editors), which then also offer look-around assertions.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

On 11/28/2018 at 5:05 PM, MikeW said:

The request was for GREP as used in InDesign, which I believe uses PCRE (including in its JavaScript).

InDesign uses the Boost libraries for its GREP. Those are probably Perl-compatible -- InDesign's GREP is very powerful. InDesign's JavaScript (ExtendScript), however, uses standard JS regular expressions, much less powerful than InDesign's (e.g. no lookbehind, no Unicode properties).

Peter

Link to comment
Share on other sites

7 hours ago, Peter Kahrel said:

InDesign uses the Boost libraries for its GREP. Those are probably Perl-compatible -- InDesign's GREP is very powerful. InDesign's JavaScript (ExtendScript), however, uses standard JS regular expressions, much less powerful than InDesign's (e.g. no lookbehind, no Unicode properties).

Peter

Many thanks for the clarification, Peter.

Mike 

Link to comment
Share on other sites

This is a rather interesting source of confusion.

"grep" is a UNIX command that scans through files using regular expressions.  Those regular expressions are much less capable than the PCRE ones.

Referring to these patterns as being "GREP" patterns suggests the use of the less capable patterns used by that command.

They are poorly named.

Link to comment
Share on other sites

On 11/30/2018 at 2:35 PM, fde101 said:

This is a rather interesting source of confusion.

"grep" is a UNIX command that scans through files using regular expressions.

Well "grep" is a program not a shell command or the like here, it's initially developed by Ken Thompson for AT&T UNIX.

The term "grep" stands for...

or

  • global search for a regular expression and print out matched lines

...and stems from the old Unix ed line based texteditor (similar to ex and edlin).

Regular expressions have been and are widely used and are very popular on Unix systems and their derivates. I recall that when I learned C programming and working with Unix systems, one very nice book in the past times was "UNIX-Toolbox: Programming with UNIX" (from Brian W. Kernighan and Rob Pike) which was full of infos and usage references to most regular expression capable programs like awk, ed, emacs, grep, sed, vi/ex, etc.

However, over the years things have changed, been reworked and enhanced in the Unix world, new more powerful things like Perl discovered the scene and established then new standards in this regard.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

7 hours ago, v_kyr said:

Regular expressions have been and are widely used and are very popular on Unix systems and their derivates.

Yes, and rightly so.

 

Really, the fact that this is named "grep" search / styles is a rather odd choice, because it has nothing to do with grep.

They are really "regular expression" search / styles, and even on UNIX platforms there are quite a few text editors and other programs that support "regular expression" search capabilities.

"grep" is just one tool on UNIX that happens to use regular expressions, and based on the above commentary it seems InDesign even uses more perl-like regular expressions (a superset of what grep can do) so naming the feature based on a tool that happens to use a smaller subset of regular expression functionality than "grep" uses is kind of strange.

Link to comment
Share on other sites

30 minutes ago, fde101 said:

Really, the fact that this is named "grep" search / styles is a rather odd choice, because it has nothing to do with grep. 

They are really "regular expression" search / styles (...)

Since GREP means "Global Regular Expression Print", it appears logical to name this missing feature "grep search".

 

On 11/30/2018 at 6:39 AM, Peter Kahrel said:

InDesign uses the Boost libraries for its GREP. Those are probably Perl-compatible -- InDesign's GREP is very powerful. InDesign's JavaScript (ExtendScript), however, uses standard JS regular expressions, much less powerful than InDesign's (e.g. no lookbehind, no Unicode properties).

Peter

It may be a coincidence, but not necessarily, that a newbie named Peter Kahrel has an eye on this topic.

https://www.oreilly.com/library/view/automating-indesign-with/0596529376/

macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1

Link to comment
Share on other sites

On 12/14/2018 at 1:17 PM, fde101 said:

Really, the fact that this is named "grep" search / styles is a rather odd choice, because it has nothing to do with grep.

They are really "regular expression" search / styles, and even on UNIX platforms there are quite a few text editors and other programs that support "regular expression" search capabilities.

"grep" is just one tool on UNIX that happens to use regular expressions, and based on the above commentary it seems InDesign even uses more perl-like regular expressions (a superset of what grep can do) so naming the feature based on a tool that happens to use a smaller subset of regular expression functionality than "grep" uses is kind of strange.

Well the thread title is missing at least the "grep like find/replace..." here, since yes, grep is just one of those older tools which offers a text based regular expressions matcher (see the article from Brian Kernighan in the "Beautiful Code book".

 

Quote

...

Stephen Kleene invented regular expressions in the mid-1950s as a notation for finite automata; in fact, they are equivalent to finite automata in what they represent. They first appeared in a program setting in Ken Thompson’s version of the QED text editor in the mid-1960s. In 1967, Thompson applied for a patent on a mechanism for rapid text matching based on regular expressions. The patent was granted in 1971, one of the very first software patents [U.S. Patent 3,568,156, Text Matching Algorithm, March 2, 1971].

Regular expressions moved from QED to the Unix editor ed, and then to the quintessential Unix tool grep, which Thompson created by performing radical surgery on ed. These widely used programs helped regular expressions become familiar throughout the early Unix community.

Thompson’s original matcher was very fast because it combined two independent ideas. One was to generate machine instructions on the fly during matching so that it ran at machine speed rather than by interpretation. The other was to carry forward all possible matches at each stage, so it did not have to backtrack to look for alternative potential matches. In later text editors that Thompson wrote, such as ed, the matching code used a simpler algorithm that backtracked when necessary. In theory, this is slower, but the patterns found in practice rarely involved backtracking, so the ed and grep algorithm and code were good enough for most purposes. Subsequent regular expression matchers like egrep and fgrep added richer classes of regular expressions, and focused on fast execution no matter what the pattern. Ever-fancier regular expressions became popular and were included not only in C-based libraries, but also as part of the syntax of scripting languages such as Awk and Perl.

...

So a thread title like "find/replace feature which supports regular expressions" would probably have been better here, but on the other side most people still know what is meant here with grep as a synonym. - In this sense ...

real_programmers.png.7e630bd4bbd3091480b7600ec67cabdb.png

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

  • 2 weeks later...

One more vote for GREP. I have used it in two long InDesign documents, and it just saves tons of work. I would add that being able to group several GREP commands together would be incredibly useful. But I'd be more than happy with individual GREP commands. 

Link to comment
Share on other sites

The discussion of what to call this has been interesting to me (I’m just now catching up on the thread). I am familiar with regular expression from my experience in programming (predominantly PHP, which does use PCRE). In the last few years, I have come into the publishing world, where I noticed InDesign calls searches by regular expressions “GREP” in its Find-Replace dialog. I have known there is technically a difference, but I have not really paid attention to what it is.

When naming this thread, I supposed there were many more readers familiar with InDesign than with programming, so I named the thread according to what I supposed people are familiar with. If Affinity chooses to add this feature and call it “Regular Expressions,” then perhaps that is the best and most consistent, but honestly, I’ll be glad to have it even if they choose to call it “GREP” even if slightly inaccurate, or even “Geeky Super Search.”

As to flavor, sure, I would be happy with PCRE, as that is what I know. I have occasionally come across features that work in regular expressions in PHP that didn’t work in InDesign GREP—I can’t remember what it was, maybe negative lookbehind, or some such. However, I suppose that we most likely would get whichever flavor is built into the programming architecture in which the apps are written. I only know web programming, so I am guessing here, but I would think that if they use the functions provided by the programming languages they are using, then it should be a very easy thing to implement.

And just for fun, here is the resource I use for building my regular expressions, both for use in InDesign and also for programming. Perhaps some of you may find it as useful as I have:

https://regex101.com

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
  • Staff

People who have contributed to this thread may be interested in our first beta release (#249) to include Regular expressions in find and replace, and help us test this improvement to the feature.

Quote

Regular Expressions for Find and Replace

  • We have added the facility to Find and Replace using perl type (or ‘ECMAScript with perl extensions’) regular expressions
  • The options to turn the feature on are found on the Find and Replace panel search options drop menu
  • 'Regular Expression' - Find / Replace will be performed using the "C" or "POSIX" locale
  • 'Locale Aware Regular Expression' - Find / Replace will be performed using the locale inferred from the text being searched and locale aware collation is implied
    • Please note that a 'Locale Aware Regular Expression' has to treat each block of text with a different language setting in isolation

Affinity Publisher 1.7.0.249 for Mac

Affinity Publisher 1.7.0.249 for Windows

 

Patrick Connor
Serif Europe Ltd

"There is nothing noble in being superior to your fellow man. True nobility lies in being superior to your previous self."  W. L. Sheldon

 

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.