Back

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

  • You must be logged in to reply to this topic.Login

I can't figure this GREP search out

Return to Member Forum

  • Author
    Posts
    • #56163
      Billy Chase
      Member

      It's for styling URLs. I have part of it.

      (?i)(http|ftp|www)(S+)(.l{2,4})|(S+)(.l{2,4})

      That can grab anything up until a forward slash.

      I've tried adding (/?) but that's not right.

      What am I doing wrong?

    • #56164

      First off, your GREP is even less readable than they normally are, because this forum's text editor eats single backslashes. To see one //, you need to insert two. To see two ////s, you need to insert four.

      If I mentally fill in backslashes at like places, it looks like it grabs an http, ftp, or www prefix, then anything non-whitespace, followed by a period and between two and four lowercase chars — presumably, to catch postfixes in the shortest form (www.adobe.com) up to common file extensions in the longest form (www.yadayada.com/yadaydaya.html). (I wonder where the parenthesized stuff and the OR bar came from — they don't appear to add anything useful …)

      Appending a slash after this makes no sense, as it will never (well — rarely) match a subfolder after the initial web site name (www.adobe.com/indesign <– this will NOT match the pattern).

      As I see it, all you need to do is remove the period-plus-extension stuff at the end. You don't even have to add the slash, it will be picked up by the not-a-space sequence. It will have other repercussions, in it that you'll also pick up much more unwanted stuff as well. Then again, the original expression wasn't bullet proof either — but neither is any URL catching GREP I've seen so far.

    • #56169
      Billy Chase
      Member

      Thanks for the reply Jongware. You know your stuff. How did you get to understand GREP so well? I have a hard time grasping it and figuring it out. I'm hoping it will click soon enough.

      Thanks, again.

    • #56171

      It only clicked for me when I got a good code editor with loads of simple examples in its help — before that, I was as befuddled as anyone else!

      To construct complicated GREPs, I create a GREP style that applies a character style that's glaring obvious (say, red Arial Black with a green underline), click on the Preview button, and start typing away until I'm sure only the items I need are highlighted.

Viewing 3 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads