Forum Replies Created
-
AuthorPosts
-
January 22, 2010 at 6:25 am in reply to: GREP replace footnote>punctuation with punct>footnote #54593
LAURENT TOURNIER
MemberHello,
With GREP, it is impossible, because footnote marker can't be entered in the Change To box. You can do it with a script.
I use this one :
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeFootnotes = false;var pattern = “[,;.]+~F”;
app.findGrepPreferences.findWhat = pattern;
var finds = app.activeDocument.findGrep();
for (var i = finds.length-1 ; i>=0 ; i–)
{
finds[i].characters.item(-1).move(
LocationOptions.before,
finds[i].characters.item(0)
);
}
app.findGrepPreferences = null;
app.changeGrepPreferences = null;January 22, 2010 at 12:23 am in reply to: GREP replace footnote>punctuation with punct>footnote #51583LAURENT TOURNIER
Member“It seems to do it fine if you use Change All“
J'en apprends tous les jours, but I would like understand why.
My example with the script is for french typo, for english you had to inverse: ~F[,;.]
If you used two regex or more, Peter Kahrel's script (chain_grep_queries) is very very useful.
January 21, 2010 at 11:25 pm in reply to: GREP replace footnote>punctuation with punct>footnote #51581LAURENT TOURNIER
MemberHello,
With GREP, it is impossible, because footnote marker can't be entered in the Change To box. You can do it with a script.
I use this one :
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeFootnotes = false;var pattern = “[,;.]+~F”;
app.findGrepPreferences.findWhat = pattern;
var finds = app.activeDocument.findGrep();
for (var i = finds.length-1 ; i>=0 ; i–)
{
finds[i].characters.item(-1).move(
LocationOptions.before,
finds[i].characters.item(0)
);
}
app.findGrepPreferences = null;
app.changeGrepPreferences = null;LAURENT TOURNIER
MemberHello
This is a very good regex, and I am sure I will need it one day (but for french biblical references, sometimes with roman numbers, I Cor., XV, 14-17 ; II Rois, XVIII, 2 [second roman numerals in small caps]).
For index, without using a character style, I use a Peter Kahrel's JavaScript : Chain_GREP_queries (download here). Using Test mode, “the script collects all instances matched by the Find What expressions in all selected queries and lists these matches in a new document.” To have a look of the result, you can see my blog, indigrep, here.
After, you can index with another script as IndexBrutal (Marc Autret) or one of P. Kahrel (here).
Best and thanks
LAURENT TOURNIER
MemberHello
This is a very good regex, and I am sure I will need it one day (but for french biblical references, sometimes with roman numbers, I Cor., XV, 14-17 ; II Rois, XVIII, 2 [second roman numerals in small caps]).
For index, without using a character style, I use a Peter Kahrel's JavaScript : Chain_GREP_queries (download here). Using Test mode, “the script collects all instances matched by the Find What expressions in all selected queries and lists these matches in a new document.” To have a look of the result, you can see my blog, indigrep, here.
After, you can index with another script as IndexBrutal (Marc Autret) or one of P. Kahrel (here).
Best and thanks
LAURENT TOURNIER
MemberHello
Are you sure about the regular expression ? I think it is (?<=w)s(?=w+[[:punct:]]+$)
In a lookbehind, the string must have the same length, i.e. the same number of characters. You can't use + * or ?
ex : (?<=figs?)d is impossible (matche a digit preceded by fig or figs)
There is no limitation in a lookahead.
LAURENT TOURNIER
MemberHello
Are you sure about the regular expression ? I think it is (?<=\w)(?=\w+[[:punct:]]+$)
In a lookbehind, the string must have the same length, i.e. the same number of characters. You can't use + * or ?
ex : (?<=figs?)\d is impossible (matche a digit preceded by fig or figs)
There is no limitation in a lookahead.
LAURENT TOURNIER
MemberHi. I am come back (too late ?)
Some others regular expressions for examples :^l for any lower case letters at the beginning of a paragraph. I don't know other solutions to uppercase than Casey D and Jongware (perhaps by changing this Peter Kahrel's JavaScript ? https://creativepro.com/con…..tility.php or using this script : https://indesigning.net/search-…..hange-case ?
[[:blank:]]+Z (or z is equal). The posix [[:blank:]], undocumented, finds 13 spaces + Tabulation (InDesign CS4). Only space, Non-Breaking Space and Tab with InDesign CS3 (both with PC, perhaps different with Mac)
LAURENT TOURNIER
MemberHi. I am come back (too late ?)
Some others regular expressions for examples :^ for any lower case letters at the beginning of a paragraph. I don't know other solutions to uppercase than Casey D and Jongware (perhaps by changing this Peter Kahrel's JavaScript ? https://creativepro.com/con…..tility.php or using this script : https://indesigning.net/search-…..hange-case ?
[[:blank:]]+\Z (or \z is equal). The posix [[:blank:]], undocumented, finds 13 spaces + Tabulation (InDesign CS4). Only space, Non-Breaking Space and Tab with InDesign CS3 (both with PC, perhaps different with Mac)
LAURENT TOURNIER
MemberHi,
@Jessereko
Just one think (I have no time now) : in a lookbehind, the length of the string must be fixed. What is why you can't use + ? *
I come back
LAURENT TOURNIER
MemberHi,
@Jessereko
Just one think (I have no time now) : in a lookbehind, the length of the string must be fixed. What is why you can't use + ? *
I come back
LAURENT TOURNIER
MemberHi,
The parenthesis, as litteral character, inside a group [ ] or negative group [^ ] doesn't need blackslash. Same think for [ { } + . ? * | ^ $
@ Jongware : thanks for explanations, it is difficult for me to explain in english.
In the regex, you can also use [^(]+
Laurent
LAURENT TOURNIER
MemberHello,
With you example, this regex works : ([^)]+only)
It finds (handbag only) and (coat only)
Laurent
LAURENT TOURNIER
MemberHi,
The parenthesis, as litteral character, inside a group [ ] or negative group [^ ] doesn't need blackslash. Same think for [ { } + . ? * | ^ $
@ Jongware : thanks for explanations, it is difficult for me to explain in english.
In the regex, you can also use [^(]+
Laurent
LAURENT TOURNIER
MemberHello,
With you example, this regex works : \([^)]+only\)
It finds (handbag only) and (coat only)
Laurent
-
AuthorPosts
