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

GREP Find space before one or more numbers

Return to Member Forum

  • Author
    Posts
    • #87286
      Anonymous
      Inactive

      Hi !

      I need to find the space before one or more numbers and replace ONLY the space (not the numbers) with a breaking space.
      Can someone help me ? GREP is going to drive me crazy ! :-)

      Thanks a lot !

    • #87298
      David Blatner
      Keymaster

      There are a ton of resources on this page:
      https://creativepro.com/resources/grep
      It sounds like you need to use a “positive lookahead”

    • #87307
      Anonymous
      Inactive

      Thanks !

      Im blocked at this point : (?<=\d)

      With a space at the end of this grep, it works but it select the space AFTER the numbers. I don’t know how to select the space BEFORE :/

    • #87308

      Lookarounds find positions, not text. Therefore it is possible to find something, but not to include it.

      Assume you are the ‘space’ ;-) and you are sitting on a time ray. If you want to find something left from you (in the past), you will have a look to your left (lookbehind). If you want to find something in the future, you will have a look to your right (lookahead).

      The code that you provide, is the shortcut for a lookbehind. So it will find a space, if it is preceded by a number.

      But what you need is a lookahead:

      \x20(?=\d)

      Kai

    • #87311
      Anonymous
      Inactive

      Waouw ! It works !! Thanks !!
      It’s like a lesson on the theory of relativity :-)

      What means \x20 ?

    • #87316

      No, it’s like learning how to play guitar. If you understand some concepts, you will be able to play your own songs.

      \x20 is the unicode value for a space-character. It’s a way to make spaces visible in your code. You can check that, if you select a space and read the value in the Information-panel. This will show you ‘0x20’. So you could write \x{0x20} or in this case the shortcut \x20

    • #87324
      Anonymous
      Inactive

      You’re totally right.

      Thanks ! I learned something.

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