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 expression help

Return to Member Forum

  • Author
    Posts
    • #61845
      smulls
      Member

      I have successfully built a GREP expression that applies a character style to all text that begins with “(ref.” and ends with “)”

      (ref[.].+)

      It works great and produces something like this:

      …hood, as well as the fabric of the community as a whole. The Community supports quality architectural and site design that is consistent with community expectations (ref. GP-4).

      Here’s where I get stuck. There are times when there are multiple sets of text that that meet the criteria in the same paragraph. The results look like this:

      …hood, as well as the fabric of the community as a whole. The Community supports quality architectural (ref. GP-4) and site design that is consistent with community expectations (ref. GP-4).

      but i need this:

      …hood, as well as the fabric of the community as a whole. The Community supports quality architectural (ref. GP-4) and site design that is consistent with community expectations (ref. GP-4).

      I’m very new to GREP and cannot figure out how to apply this character style, limiting it to just the text that starts with “(ref.” and ends with “)” and anything in between defaults to the paragraph style in which this expression is nested.

      Suggestions?

      smulls

    • #61846

      GREP is “greedy” by default, and it will try to grab as much as it can, while still doing exactly what you asked for. So in your multiple-refs case, it exactly does as told: start with 'ref”, then some unspecified other stuff, then end at (the very last) closing parens.

      Fortunately, you can switch this off and tell GREP to use the shortest possible match:

      (ref..+?)

      (Note that I inserted the — probably — missing backslashes ;) The forum software removes single s, so to get you must type \).

      There is no need, by the way, for your construction

      [.].+

      to force a “literal” full stop. Just add a single backslah before it to make it loose its magic properties.


    • #61847
      smulls
      Member

      solution:

      (ref[.].+?)

    • #61848
      smulls
      Member

      Thanks for the help and letting me know about backslashes in the forum. Your solution works perfect.

      smulls

    • #61849
      smulls
      Member

      sorry, one more thing:

      There is no need, by the way, for your construction

      [.].+

      to force a “literal” full stop. Just add a single backslah before it to make it loose its magic properties.”

      I added this because in my original construction which did not have the “[.].+” it picked up another bit of text “(references to…)” and styled it. My reasoning is to force GREP to identify “ref.” before styling. Is there a better way?

    • #62632
      angeldesigner34
      Participant

      Jongware said:

      GREP is “greedy” by default, and it will try to grab as much as it can, while still doing exactly what you asked for. So in your multiple-refs case, it exactly does as told: start with 'ref”, then some unspecified other stuff, then end at (the very last) closing parens.

      Fortunately, you can switch this off and tell GREP to use the shortest possible match:

      (ref..+?)

      (Note that I inserted the — probably — missing backslashes ;) The forum software removes single s, so to get you must type ).

      There is no need, by the way, for your construction

      [.].+

      to force a “literal” full stop. Just add a single backslah before it to make it loose its magic properties.



    • #62633
      angeldesigner34
      Participant

      I have a bit of a GREP dilemma. How do you find consecutive tabs?

      <TAB> = Actual Tab

      Company:A<TAB>Address:A<TAB>Phone:A<TAB>Contact Person:A<TAB>Web Address:A

      Company:B<TAB>Address:B<TAB>Phone:B<TAB>Contact Person:B<TAB>Web Address:B

      RESULTS:

      Company<TAB>Address<TAB>Phone<TAB>

      <CARRIAGE RETURN>Contact Person<CARRIAGE RETURN>

      Web Address

      I want to select all the info before the fourth <TAB> including the <TAB> and replace with the same info except with a <CARRIAGE RETURN> before and after the info.

    • #62922
      Anonymous
      Inactive

      something like (T+tT+tT+t)(T+)(t)

      replace with: $1r$3r

      maybe?

Viewing 7 reply threads
  • You must be logged in to reply to this topic.
Forum Ads