Ok - so how does one these things?
I've read the help - I've got a GREP manual from O'Reilly Media
But since CS3 I cannot understand how modifiers work.
Any of them, at all. Not sure when I should use them?
Is the GREP manual you have GREP in Indesign CS3/4 by Peter Kahrel? If so, look at pages 41-42 under "Single-line and Multi-line" for an explanation of multi-line and single line. Page 22 also has a bit of explanation about case-sensitive searches under "Replacing with Wildcards." The best example would be search where you want to find both Figure and figure. You would need to search for "(?i)figure".
Page 52-53 also includes a brief key as to what each of the modifiers do. Good luck!
Well I guess it does explain it. But I don't really get it.
It would be nice to know when a good time to use these would be. I do a lot of grep searches and I sometimes think that the modifiers would really help.
But I've no clue how to use them and I can fudge up some large GREPs to find what I need. But I guess I'm just looking for a bit more direction on it.
Honestly, I've only used single-line or multi-line functionality once or twice. You would use it if you wanted to search for something that spans mutiple paragraphs, like any text that falls inbetween two numbers (see attached). This is necessary because the . wildcard finds everything except return characters. When I removed the single-line indicator (?s) and changed the GREP string to include standard carriage returns using either .+?|~b+? or [.~b]+? it couldn't return the same result. I think this is why the single-line and multi-line functionality exists.
Case-sensitve modifiers can be used as outlined in my previous post, to find a string of characters no matter their case. Unlike text find/change, GREP find/change is case sensitive by default, so you have to use (?i) to turn it off.
From the documentation page on my own WhatTheGrep:
|(?i) (case insensitive)||YES d|
|(?s) (dot matches newlines)||YES d|
|(?m) (^ and $ match at line breaks)||YES d (default mode)|
|(?x) (free-spacing mode)||YES d|
|(?n) (explicit capture)||no|
|(?-ismxn) (turn off mode modifiers)||YES d|
|(?ismxn:group) (mode modifiers local to group)||YES d|
|d Any of i, s, m, x, or none at start, none or only one after the hyphen|
(The YES/no is whether ID supports the modifier.)
Usage: something like (?i:this) to find case sensitive (the default) but "this" case insensitive. Or the other way around: (?i)Case sensitive but (?-i:this) not.
(?m) is for "multiline mode", the default; (?-m) makes "^" and "$" functionally equal to \A and \Z (start and end of story). (?s) -- not the default -- makes . match a hard return, otherwise hard returns end a .+ sequence. (?-s).+ will match everything up to the end of story. (?x) turns on "comment mode": all regular spaces are ignored unless they are escaped with a \ (so the previous sentence will be searched as "turnson"comment mode":allregularspacesareignoredunlesstheyareescapedwitha " -- note the final space!), and in addition, everything after a '#' up to the end of the GREP expression (actually, the end of a single line) will also be ignored, so you can end all of your GREPs with (?x)# This is a comment.
All of these should be explained in Peter's book! If you think it lacks detail, just say so, and he'll be sure to fix it in a next edition
Europe, Middle East and Africa