Jump to content

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.

Share this post


Link to post
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.7.1 ◆ Affinity Photo 1.7.1 ◆ OSX El Capitan

Share this post


Link to post
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

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Count me among those who also think this is a must-have in a pro-level application. GREP styles saved my proverbial derrière in more than one InDesign project already…

Share this post


Link to post
Share on other sites

RE find and replace and RE styles are so important that they were my first thought when I got to know that Affinity is going to make Publisher.

Of course richer the flavour is more powerful it gets.

But it is a must have for me. So please add any.

Share this post


Link to post
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.7.1 ◆ Affinity Photo 1.7.1 ◆ OSX El Capitan

Share this post


Link to post
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.

Share this post


Link to post
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.12.6,  Macbook Pro 15" + Eizo 24"

Share this post


Link to post
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.7.1 ◆ Affinity Photo 1.7.1 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites

Yes, please! GREP in find&replace and in paragraphs styles. Essential to me for automatically raise 2s and 3s for units of measurements, English ordinal numbers or the female endings of academic titles in german texts.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
5 minutes ago, Clanks said:

Uhm, what does GREP stand for?

 

 

On 12/13/2018 at 10:48 PM, v_kyr said:

The term "grep" stands for...

or

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

 

Share this post


Link to post
Share on other sites

Yep, the types of patterns we are discussing are regular expressions.

The "grep" utility is one traditional UNIX command that happens to use regular expressions, as do many other tools and programs.

Share this post


Link to post
Share on other sites

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.

Latest releases on each platform 

Share this post


Link to post
Share on other sites

Great, thank you. It's incomplete (e.g. no lookahead and lookbehind yet) and still a bit buggy (bug reports submitted), but it's early days and I look forward to a full implementation.

P.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×