Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using InDesign-compatible Posix expressions

From: Learning GREP with InDesign

Video: Using InDesign-compatible Posix expressions

The last grouping of metacharacters in the Special characters menu are the Posix metacharacters. Posix stands for Portable Operating System Interface and it's a form of writing expressions that's slightly different from what we've seen so far. So let's take a look at the difference between Posix and some of what we've seen so far. I am on page 3 of this document and my cursor is within the Body Text paragraph style. I am going to right-click on that style name, choose Edit Body Text from the Context menu and in the Paragraph Style options, I will switch to GREP style.

Using InDesign-compatible Posix expressions

The last grouping of metacharacters in the Special characters menu are the Posix metacharacters. Posix stands for Portable Operating System Interface and it's a form of writing expressions that's slightly different from what we've seen so far. So let's take a look at the difference between Posix and some of what we've seen so far. I am on page 3 of this document and my cursor is within the Body Text paragraph style. I am going to right-click on that style name, choose Edit Body Text from the Context menu and in the Paragraph Style options, I will switch to GREP style.

I am going to create a new GREP style just so we can gain access to this menu at the end of the To text field and take a look at the Posix metacharacters. Down at the bottom of the list is Posix and there are a handful of metacharacters here that are a different form of Wildcard. Many of them overlap Wildcards we've already seen in this menu. So they're repetitive and just a different way of saying something we've already covered in previous movies. However, there are a couple of Posix meta- characters that could prove very useful.

I will just quickly go down the list. They're named slightly differently, so it's a little bit easier to figure out what a Posix metacharacter means just by looking at it. The first one alnum is any alphanumeric character, so any upper or lowercase letter or any digit. Alpha is any alphabetical character, upper or lowercase. Digit is any digit. Lower is any lowercase character. Punct is any punctuation character. Space is any white space. Upper is any uppercase character. Word is any word character.

So this is a lot of overlap between Wildcards we've seen in previous movies. The only thing that's unique here, at this point is punct, which specifies punctuation in one fell swoop. You don't have to create a character set that includes every possible bit of punctuation. It's automatically handled by this Posix metacharacter. So that's a very useful one. The next one down here, xdigit, this speaks to the computer programming origins of GREP in general and certainly of Posix. It refers to any hexadecimal digits.

So it is placed inside of a page layout application. It doesn't really reveal itself, I don't think, for most of us. But if you use hexadecimal digits in your documents for some reason and want to apply GREP style to them, this is the metacharacter for you. The last Posix metacharacter is even different than all the other ones, which are different from the metacharacter syntax we've seen so far and the example in this list is just two opening square brackets an equal sign the letter A and another equal sign and two closing square brackets.

Let's take a quick look at this one, just so we can understand what it is. As it appeared in the menu with the A, that is just a visual cue for your benefit of the syntax for this type of metacharacter. If I actually type in 'a' here and then, from the Apply Style menu, I choose my Red character style. Let's take a look at what this does on the page. I will click off here and notice that it has matched every lowercase A and every uppercase A. Beyond that, and what you can't see here, because there are no instances of it, is that it will also match every accented A. Everything with an accent grave, everything with an accent acute, any variation, any equivalent of an A that's defined by that typeface is going to be matched by this character.

So it's very broad if you're working with text that has a lot of accented characters and you need to account for every variation of A or every variation of an accented vowel or any character with multiple variations, this is the way to do it. It's also a way to account for, at a minimum, both upper and lowercase instances of that letter. The same would apply if it was C, upper and lowercase C's and the accented C's and so on. So whatever you put in there any single character, you're going to get every variation for that character. So that's a unique Posix metacharacter that's very useful.

I am going to clear that out here and the other Posix metacharacter I mentioned earlier as being unique to Posix, and very useful, is the punct Posix metacharacter, which accounts for all punctuation, and there is an example from a previous movie where we were constructing negative character classes to find anything that's not a vowel. If the goal was actually to find only consonants, defining a negative character class as anything that isn't a vowel grabbed up a lot more text than we intended.

It grabbed punctuation and white spaces and any number of other things. So let's reconstruct that character set using an opening square bracket, the carrot symbol, which means match everything in this character set that isn't what I type following this symbol. And we put in 'aeiou' and, in uppercase, 'AEIOU' and close that off with a closing square bracket. That's a negative character set that says find anything that is not an upper or lowercase vowel. I am going to change the character style to yellow highlight because that's the only way I can see the white spaces that it finds as well.

This is what we've found. It excluded vowels, but included every single other type of character. If I were to try to eliminate all of the punctuation, I'd have to remember every potential punctuation mark there is in the alphabet. That's not time well spent on my part, so I can take advantage of that punctuation Posix metacharacter and include it inside of this character class, along with these standard characters. So, I am going to the Special characters menu, down to Posix and pick that punct metacharacter.

Now there is one problem that I am going to reveal, before we even click off here. All Posix metacharacters are in fact character classes already. They have two square brackets on either side of the expression and when they're just used by themselves, that's fine. That's exactly how they're supposed to appear. But if you put a Posix character inside of a character class, you need to get rid of that extra square bracket at the end and the extra square bracket at the beginning. When I do that and click off here, notice all my punctuation has been deselected because I've defined punctuation, any form of punctuation, as something to be skipped over and that makes this easier to define.

Now I can put in any white space and eliminate that. At this point, I've now described every consonant and the punctuation metacharacter made it much quicker and easier to do. So even though Posix expressions are all the way at the bottom of the menu, don't follow the same syntax as most of the other metacharacters we've seen and often repeat the functionality of many Wildcards, these punctuation and character equivalent Posix expressions, in this list, are hidden gems that describe character sets that are otherwise very difficult to describe with conventional metacharacters.

Show transcript

This video is part of

Image for Learning GREP with InDesign
Learning GREP with InDesign

42 video lessons · 12820 viewers

Michael Murphy
Author

 
Expand all | Collapse all
  1. 1m 33s
    1. Welcome
      1m 4s
    2. Using the exercise files
      29s
  2. 7m 56s
    1. What is GREP?
      1m 53s
    2. Text searching vs. GREP searching
      2m 35s
    3. Working with GREP and InDesign
      3m 28s
  3. 46m 4s
    1. Using metacharacters, the building blocks of GREP
      6m 37s
    2. Escaping out metacharacters
      2m 49s
    3. Building with wild cards
      9m 9s
    4. Understanding undocumented wild card "opposites"
      3m 11s
    5. Specifying locations
      7m 4s
    6. Learning the undocumented location metacharacters
      4m 45s
    7. Using repeat metacharacters and defining the shortest match
      5m 45s
    8. Specifying exact matches and ranges
      2m 52s
    9. Finding content that doesn't exist with zero functions
      3m 52s
  4. 43m 26s
    1. Creating "or" conditions
      5m 24s
    2. Building subexpressions
      5m 52s
    3. Using character sets to create custom wild cards
      7m 3s
    4. Using negative character sets
      3m 2s
    5. Finding around text with lookbehind and lookahead
      8m 1s
    6. Building with modifiers: Case sensitivity
      4m 0s
    7. Building with modifiers: Single-line and multi-line
      3m 10s
    8. Using InDesign-compatible Posix expressions
      6m 54s
  5. 49m 18s
    1. GREP styles vs. nested styles
      6m 10s
    2. Styling specific words or phrases
      3m 18s
    3. Describing inconsistent text
      6m 59s
    4. Describing and styling prices
      6m 55s
    5. Applying multiple character styles to the same text
      6m 8s
    6. Describing and styling email addresses
      10m 48s
    7. Dynamically fixing orphaned words with GREP
      9m 0s
  6. 33m 30s
    1. Adding more to the mix: GREP Find/Change
      1m 41s
    2. Understanding queries
      8m 20s
    3. Using formatting and styles as Find/Change criteria
      5m 20s
    4. Preserving and recalling using subexpressions
      7m 49s
    5. Backreferences in search queries
      3m 8s
    6. Cleaning up text with GREP
      2m 45s
    7. Creating a GREP-based text cleanup script
      4m 27s
  7. 43m 45s
    1. Describing imported spreadsheet data
      6m 56s
    2. Rearranging imported spreadsheet data
      7m 17s
    3. Applying styles and formatting with GREP
      11m 14s
    4. Describing and standardizing phone numbers
      9m 20s
    5. Inserting anchored objects with GREP
      8m 58s
  8. 27s
    1. Goodbye
      27s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Learning GREP with InDesign.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.