Use Grep to find/replace

I'm trying to find how to use GREP in find/replace of chage the formatting of a text which is a spreadsheet.

I worked on the GREP query "~ b (\d\d) ~ b ', which is a paragraph return, followed by two digits, followed by another paragraph of return

and then it is replaced by ' \t $1 ~ b ', which is a tab, found two numbers and a paratrooper returned.

What I have to do is change the query to search for ANY number of digits, (which may be delimited by commas: e.g. 23, 36, 48, 50), then replace with a tab + found text.

I guess what I'm looking for is a way for the query find "any text between two paragraph returns, no matter what that length", but I don't know how to do this. All of the generic options seem to find a single exampler (a figure, a character etc.)

And you came so far

Repetition operators are? (zero or one), * (zero or more) and + (one or more times). You can also specify the exact number: {at least up to the}.

All of these operators are "greedy" by default - they match as much as possible. To to match as less as possible (which I'm sure you will come, sooner or later), add another? After the expression of repeat.

If this is a number, then possibly another (which will be always included):

\D\d?

and what a figure, then zero or as much as 9999999,93856 million:

\D\d*

which is functionally identical

\d+

And it is between 3 and 8 figures but will be forced to use the shortest possible match:

\d{3,8}?

Having said that: a quick & dirty solution for your real problem is to find any amount of numbers, spaces, and comma:

~ b [\d,] + ~ b

(there are more here because otherwise it would correspond also to an empty line). The [..] a list of the hooks - it will match to any unique inside code.

A more complicated but 'cleaner' way is looking very precisely that for many, comma, space, number sequences - it is cleaner because it lines poorly trained (comma without a space) is fried!

(She also has another code - operators in parentheses. Look at their place in a good reference GREP - lost people are enthusiastic about Peter Kahrel O'Reilly title, because there on the use of GREP in InDesign.)

~b\d+(, \d+)*~b)

Tags: InDesign

Similar Questions

  • Select a specific area to convert a tab using GREP or find/replace

    Hello

    I'm working on a very long list that always has a space to be converted to a tab. No one knows how quickly using find/replace or GREP?

    Example:

    2068 characteristics of fallers vs Non-abatteurs in individuals receiving Services in a hospital-based home health agency: case report

    The space after the 4 digits must be converted into a tab. I have hundreds of them to do, always a space after 4 figures to be a tab.

    Any help would be appreciated!

    Thank you!

    Enter in the search field: ^ (\d{4})# (replace ' #' with a space!))

    Replace with this: $1\t

  • Using InDesign Script find/replace

    Hi guys,.

    I use Mac OS (Mountain Lion), Adobe Indesign CS6 and AppleScript 2.3.2 (Version 2.6.1 (152.1)

    In Indesign CS6, can it is possible through Applescript to find a specific font name and replace it with a character style.

    Example of

    Find - "Times New Roman MT Std / Bold" replace "" text BOLD"" character Style

    If it is possible, it saves me one day.

    Thanks in advance.

    Josh

    Like this...

    tell application "Adobe InDesign CS6"
        activate
        set find text preferences to nothing
        set change text preferences to nothing
        set properties of find text preferences to {applied font:"Mistral", font style:"Bold"}
        set properties of change text preferences to {applied character style:"myCharacterStyleName"}
        change text
    end tell
    
  • How to replace the spaces before and after a Word with tabs using GREP or search - replace

    Here's the scenario:

    I have a paragraph with spaces (can be 1 or more) at the beginning (before the first word) and a single space after the first word (is be a number if this matter - which may be a single digit or more).

    I'm looking to replace the spaces before each paragraph with a single tab and replace one tab so of space after the first word (number). In addition, I would like to apply a paragraph style to it.

    Thank you very much in advance for anyone who can find a solution. It sounds like a solution of some sort GREP but can't nail. Thank you.

    ^(\s+)(\S+)(\s+)

    and replace with \t$2\t and define the change of setting fit your style.

  • How can I use GREP to find only 5 numbers?

    Hello

    My document is hundreds of product codes for example 12111

    I want to change the formatting of these codes include a space after the first two digits, e.g. 12 111

    I start there: (\d{2})\d{3} but he finds the first five digits of a number any > = 5)

    So I moved to these: ------< (\d{2})\d{3}~b or------< (\d{2})\d{3}\ > they work well but include numbers like this: 457 12345 78 and 000 00 12345 ))

    I don't want to change the numbers like these that the document contains several numbers of patent/CRD.

    So basically, I need to find 5 digits only. Excluding the spaces before and after.

    Thank you

    Paulo19 wrote:

    It always takes the number of places for example 457 12345 78 and 12345 000 00

    No it does not pick up the spaces. What you want is to find 5-digit numbers have no number before or after.

    Try this one:

    (?

  • GREP find/replace + paragraph Styles

    Hello

    I'm editing a long document and have benefited from the assistance of the community already, but being new GREP Style, find/replace, I need to ask for additional help.

    Below a screenshot of the script (original). Two blocks of text you see anticipated by the icons have have styles of different paragraphs. Icons are placed like custom glyphs.

    Now, the last line with C2, 9, 14,... is the target of this post. They are buses of London and I created a paragraph with another icon. The copy that I work with unfortunately is as you see. Buses will follow «;»

    Resulting to place a \r after the semicolon and assign the new paragraph style. The item to work with is (probably) the last "," before the registration of the bus. All entries have it in the same way, where a search/replace global grep should work fine.

    My attempts:

    I used of a previous debate (? < =------;)) [^ ;] + $ to match everything from the end until the last semicolon, but then I found the problem preserving the matched characters and placing \r (using the (? < =-;). start at the beginning and stops at each point comma + space)

    So question: how to stop at the first semicolon at the end and replace the space with \r to create a new paragraph?

    Then, it is two question :-)

    From my previous attempts, I noticed that when you replace the semicolon + space with \r, and change the style of paragraph at a time (from Rail to Bus) caused the Rail paragraph style change (logic) to the style of Bus. So I tried to say the paragraph style of the track "Following paragraph Style is style of Bus" (and not to change the paragraph style in find/replace), but in a way that no longer works.

    Second question is: given to split the find/replace in two steps, how then transform / apply to newly created paragraph the correct style of Bus?

    Thank you in advance for your valuable assistance. So far, the community has been great!

    Antonio

    Original

    Screen Shot 2016-07-12 at 22.32.23.png

    Result for

    Screen Shot 2016-07-12 at 22.54.51.png

    Hi Antonio,.

    If I understand correctly, in 2 regex [1 click play with Multi/find-replace our friend Martinho da Gloria]:

  • Do find/replace multiple records at the same time?

    Hello

    I wonder if there is a way to apply the options find/replace, I select all the records that I have given merged in my InDesign file.

    Reserved spaces will not import my database spaces, example if I

    Model InDesign: < < bird > >

    < < beak > > < < beak value > >

    .csv:                              bird's beak,,, value of beak

    Eagle, beak:, Hung

    I get

    InDesign after the merger of data: Eagle

    beak: hung

    No spaces came with the merger.  If there is an option to preserve the spaces, it would be the simplest solution. However, I'm not finding such a command, so I would like to add a special character after my colon in the .csv and then use ID to find/replace this character in each of my files in a space or two.  Any ideas?

    Thank you.

    Edit: even on a single record, find/replace is not applied to my output document, either... Its release the special character that I wrote in the fields of .csv instead of space, it is supposed to transform.

    Post edited by: EX_Achilles

    Yes.

    Make sure that you set the scope of the search and replace of the Document. He may have missed the selection or history.

  • Use Grep to add superscrpt style symbol character $

    I have a style of object which, among other things, apply a style of papragraph, in this paragraph style, I want to use GREP to find any instance of $, and apply a character style

    the problem I have is that it seems not recogize the symbol $

    In GREP, you must escape the symbol $ . Use: \$

    @+

    Marc

  • InDesign CC Grep find/replace to replace the character of space per paragraph (fly)

    Hello InDesigners,

    I'm trying to clean up a 99 page document. In the file, titles of chapters, in capital letters, followed by a space, which is then followed with text more uppercase there. This always occurs at the beginning of a paragraph.

    I'm trying to target the space character that appears just after the number of chapter and Exchange to a number (fly).

    For example:


    CHAPTER 22 SUNDAY UNDERGROUND

    I want the Grep to change this as follows:

    CHAPTER 22

    SUNDAY UNDERGROUND

    I know that to do this job, I need to use positive look behind and positive Look Ahead, at first, I just tried to isolate CHAPTER 22 using the following:

    ^ \u{2,}\s\d+

    It worked. However, as soon as I cut and paste into P.L.B., find/replace says that it does not match.

    (?<=^\u{2,}\s\d+)\s


    The culprit seems to be the comma that comes just after the number 2. If I take, I get a match, but just not the one I wanted.


    Why P.L.B. does not accept the comma as part of the range in my definition grep?


    (FYI, I prefer to use wildcards with a specified scope, rather than literal text).

    It is indeed the comma, and the reason why it does not work because the flavor of InDesign's GREP does not allow a variable length argument in its lookbehinds. And the construction "has {x, y}" indicates a variable length.

    "Chapter" only you know how many characters to uppercase, and even the exact text, you can use

    (?<=^CHAPTER>

    the first chapters to a number, then

    (?<=^CHAPTER>

    for the rest. In your version of InDesign, I guess there is also a possible solution with the fairly new \K "forget - me" operator but I have not yet enough experience with that. It should look like this:

    ^ \u{2,}\s\d+\K\s

    but you will have to experiment a bit to see how to work with the replacement string.

    In addition, you should only use the name of "fly" for a character that looks like this: "¶". The code that you insert will call it a 'return' or 'paragraph return. Initially, I took your question literally, and it sounded as if you were after this result: "CHAPTER 22 ¶ SUNDAY UNDERGROUND"

  • Find/replace style cell with GREP

    Hi all, (my first post here)

    I found a script very useful on this forum to find/replace cell styles in an array. I adapted the script using Peter Kahrel ebook for use with a GREP query.

    I've linked to a spreadsheet in InDesign CC 2014 I want to highlight the cell of new products that contain the value [Y].

    When I run the script below, I get random results.

    myDoc = app.activeDocument var

    app.findGrepPreferences = app.changeGrepPreferences = null

    app.findGrepPreferences.findWhat = "\[\u\"]

    var myFound = myDoc.findGrep)

    for (i = 0; i < myFound.length; i ++)

    {

    If (. parent.constructor.name myFound [i] == "Cell")

    {

    . parent.appliedCellStyle myFound [i] = "New_Product_Cell".

    }

    }

    Modify the script that I wrote above.

    Otherwise your discovery is just '[u]' ==> multi-ad found is--> Direct manufacturer name


    Jarek

  • GREP code for find/replace

    Hello world

    I have a list of about 500 entries, with each entry formatted as follows:

    First name [tab] [tab] [tab] State level

    I need to do a find/replace using GREP code that will target the tab between the first and last name and replace it with a space. Then I need to target the tab between the name and the State and replace it with a comma and a space. Then finally, I need to focus on the tab between the State and the level and also replace it with a comma and a space.

    I was wondering if someone could tell me what would be the code for this type of operation?

    Appreciate any assistance.

    To find

    ^([^\t])+\t

    Replace

    $1 [space]

    To find

    \t

    Replace

    [space]

  • Using find/replace

    Is it possible to use the search/replace on an array of text feature?  For example, I want to search my document for any type of [Text1, Text2, Rem3 Rem4] and change the style of paragraph on this text.  I know I could create 4 different searches, but since they all change the same paragraph style, it would be much easier to just use a.  Thanks for any help.

    Yes, if you have InCopy CS3 or CS4, you can use GREP find/replace to do what you want.

    1. Discover all the stories, then you can find/replace
    2. Edition > find/change, GREP tab
    3. In find it this field, enter "text 1 | Text 2 | Text 3 "(sans les guillemets)." The vertical bar character means 'or '.
    4. Let the change to the empty field
    5. Click the button change in format at the bottom and select the name of your paragraph Style in the first Panel of Options of Style
    6. Run a search/replace to test

    hope that helps!

    AM

  • Find followed words of periods using GREP

    Hello

    I have a GREP code that tries to identify all the words followed by periods.

    To avoid the capture of emails and Web sites, I used some negative ass.

    (? <! blatchford\.) ( ? < ! \d ?) (? <! www\.) ( ? < ! \.co\. ?) (? <! \.com) (?<!@\.) \w+?\.

    For some reason any he says no matches found, but I can't work out why.

    All boards of a person knowing most of would be great

    AHA! Yeap! is not clear!

    (^ /) is not a grep code! It's my signature as Jedi [don't you recognize the Cape, the hood and my lightsaber?  ]

    About your code, there are several reasons that may not work!

    It is difficult to find the URL, but there are several ways [complex codes] success [see Google].

    If I was me, I'ld do it in 2 steps (but in 1 light-saber struck using the Multi-Find/Change!  )

    1 / find all URLs and apply a condition, which I will call "URLs".

    2 / play this simple regex: find groups of characters (without any space between them), followed by a point AND applied unconditionally [we applied a "URLs" condition to the URL, it finds them!).]

    (insert in the areas of 'change' what you want to do with the goals!)

    (^/)

  • Moving a text box automatically using find/replace?

    I have a text box containing the given text (for example "Hello-hello12"), through several separate documents. I want to move this text box make a different location on the page of all these documents. Is it possible to do in bulk? I looked in the search/replace option, but could not find a way to do over there. I use CS6 if it matters.

    Thank you!

    It does however find/replace, but maybe the script though. Ask above in InDesign Scripting

  • Find the URL using GREP

    Hi all

    Request:

    I need to find the end of the URL with ".com", ".org", ".uk", etc. using GREP.

    for example,.

    [email protected]

    [email protected]

    rajjjesz.sir555@gmail. Corp.fr

    ()[email protected]()


    Please help for this request as soon as POSSIBLE.


    -----------------------------------------------------------------------------------

    But, I found the solution for the content to Start with "http" or "www."

    Using the Grep Code Forum is: (? I)(http|www) \S+ [\l\u|\d]

    Concerning

    Siraj



    Hi Siraj,

    Check it out now.

    var doc = app.activeDocument;

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = "[a-z0-9!" #$% &'* + / = ? ^ _'{|}] +(?:\ \. [a-z0-9!#$%&'*+/=?^_`{|}] +) * @(?: [a-z0-9] (?: [a - z0 - 9-] * [a-z0-9])? \.) + [a-z0-9](?:[a-z0-9-]*[a-z0-9])? « ;

    var found = doc.findGrep ();

    for (var i = 0; i)<>

    {

    Alert ([i] found. Happy)

    }

    Kind regards

    Cognet

Maybe you are looking for