Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 271 through 285 (of 340 total)
  • Author
    Posts
  • in reply to: need grep help #82812
    Peter Kahrel
    Participant

    Only after copying your sample did I discover what went wrong. (It did work, by the way, but not correctly — it’s always helpful to indicate in what way something doesn’t work.) Your sample has a return between the two paragraphs and a space before that return, so in the expression I gave started matching the return and/or rogue space character. This expression should fix that:

    ^(.+?)(.+?)(?=)

    stands for ‘horizontal space’, so it matsches all spaces except the hard return. And I added (?=) so that the expression doesn’t match the space after the second word.

    P.

    in reply to: need grep help #82730
    Peter Kahrel
    Participant

    ^(.+?)(.+?)

    ^ from the start of a paragraph
    (.+?) capture characters
    up to the first space
    (.+?) capture characters after the space
    up to the second space

    Refer to the first word (in the Change to field) using $1, the second word, $2

    Peter

    in reply to: Changing name order #82728
    Peter Kahrel
    Participant

    Maybe show some examples of what you have and how they should be changed.

    in reply to: Exporting Chapters as Separate Files #82727
    Peter Kahrel
    Participant

    I don’t see that error, and I use that script a lot. Try this: close all your documents so that just the book file is open, then run the script.

    in reply to: need grep help #82700
    Peter Kahrel
    Participant

    Strange, I copied the string from your original post and the Grep expression I suggested, and it works fine for me: the matches I get are “jim q. public, MD” and “Jill Neigh Bor,MD”. That’s correct, isn’t it? If it is, could you check the expression you used?

    As to [^;]+, ^ inside a character class means ‘not’. So [^;]+ means ‘mustn’t match a ; and the whole expression paraphrases as ‘match from ; up to * with no ; in between ; and *’.

    in reply to: need grep help #82665
    Peter Kahrel
    Participant

    This is a tricky one. First of all, you need to escape the asterisk in your lookahead: use (?=\*), not (?=*) (because you’re after the * character literally, you don’t want to use it as an operator).

    But when you’ve fixed that you’ll find that the expression matches “jim q. public, MD” (as expected) and “Cindy E. Verybody, MD; Jill Neigh Bor,MD” (not expected). What you need to do is match from ; to * without any intervening ;. You can do that with this expression:

    (?<=;)[^;]+?(?=\*)

    Peter

    in reply to: Exporting Chapters as Separate Files #82664
    Peter Kahrel
    Participant
    in reply to: Grep automation #82482
    Peter Kahrel
    Participant

    Assuming that two consecutive words with initial capitals are names, you can do what you want with two GREP expressions:

    1. ‘Paul’ followed by and and another name: \u+(?=\u+\u)

    This one reads ‘find a name \u+ followed by (?= a space and a name \u+ followed by a space and a name.

    2. Then find Sue Craft: \u+\u+

    The naive assumption is that a name is matched by an upper-case letter followed by any lower-case letters, which is too simple, so you’ll have to refine the pattern to include double-barrelled names, prefixes, etc.

    Peter

    in reply to: Page Break Style #82166
    Peter Kahrel
    Participant

    Maybe set the paragraph to start in the next frame (or column).

    in reply to: Non breaking space in cross reference? #82165
    Peter Kahrel
    Participant

    Unfortunately you can’t set a fixed space in the automatic number. I’d have thought that “Map^S^H.^1:.” would do it, but it doesn’t. You could do a Grep replacement, looking for (?<=Map) (?=\d) and replacing with ~S. In the Find Format panel, set the character and/or paragraph style used for cross-reference (if any).

    in reply to: Scripting to Pull Metadata #82164
    Peter Kahrel
    Participant

    Something like this:

    versionNumber = '';
    descr = app.activeDocument.metadataPreferences.description;
    if (descr !== '') {
      version = descr.match (/ver=([\d.]+)/);
      if (version !== null) {
        versionNumber = version[1];
      }
    }

    Get the description field from the document’s metadata object
    Match digits and dots following ‘ver=’
    If there is a match, it’s an array, you want item 1

    Peter

    in reply to: GREP to insert a full stop at the end of paragraphs #82152
    Peter Kahrel
    Participant

    So the question is, why doesn’t it work for you?

    (If only one could edit one’s messages. . .)

    in reply to: GREP to insert a full stop at the end of paragraphs #82151
    Peter Kahrel
    Participant

    > The dot in your [^.] matches any character. To match just a dot in the text, use \.

    Which is complete nonsense, because the dot is in a character class so that there’s no need for the backslash. Now that I tried your original ([^.])\r and $1.\r I find that they work fine over here. Though I still think that $ is better than \r, so use ([^.])$ and $1.

    in reply to: GREP to insert a full stop at the end of paragraphs #82143
    Peter Kahrel
    Participant

    Samuel,

    You were very close. Instead of ([^.])\r, use ([^\.])$.

    The dot in your [^.] matches any character. To match just a dot in the text, use \.
    Also, if you use \r you won’t match the last paragraph in a story if the story doesn’t end in an empty paragraph. $ matches the end of the paragraph even when it’s not followed by a return character.

    Colleen: using ^p (or \r for that matter) in replacements can lead to strange results at points where the paragraphs before and after the ^p have different paragraph styles.

    in reply to: Create text frame from selected text in indesign #81739
    Peter Kahrel
    Participant

    What do you mean by ‘paste into the text field again’? That the frame becomes an inline? If what you select is on a single line, then the script below would do it. Select some text, all on one line, and run the script.

    (function(){
      var width = app.selection[0].endHorizontalOffset - app.selection[0].horizontalOffset;
      var frame = app.selection[0].textFrames.add();
      app.selection[0].move (LocationOptions.AFTER, frame.insertionPoints[0]);
      var gb = frame.geometricBounds;
      gb[3] = gb[1]+width
      frame.geometricBounds = gb;
    }());

    Peter

Viewing 15 posts - 271 through 285 (of 340 total)