Forum Discussion

cindix's avatar
cindix
Copper Contributor
Mar 08, 2023

Find and replace with parenthesis

Hello again.

 

I'm trying to remove bibliographical references in my text, by searching and replacing it. 

The problem is, the references have a variable number of characters, but all of them start and end with

a parenthesis. Another thing they have in common is that all of them have a page abbreviation "p.".

 

Here's an example:

 

(POE, Edgard Allan. The Raven. 15ยช ed., California: SLG Publishing, 2020, p. 18-19)

 

So, to find them I tried this:

(\([0-9A-z]* p. *[0-9A-z]\))

 

Wildcards set to true.

 

Somentimes it would return no results, even though I knew the reference was there.

Sometimes the result would be correct, selecting the reference at the opening parenthesis and ending with the close parenthesis.

Sometimes would not work, resulting in a selection of the entire file (although would still stop at the close parenthesis, would select all the text before the open parenthesis.)

 

What is wrong here, then?

    • cindix's avatar
      cindix
      Copper Contributor
      That's the thing. There are other texts with parentheses. Which is why I was trying to distinguish it with the "p." text parameter.
      • cindix's avatar
        cindix
        Copper Contributor
        OK. So, I added a period at the beginning of the expression to prevent it to selecting all the previous paragraphs. Apparently, it was selecting the first opening parentheses amongst all the text.
        It looks like this now: (. \(* p. *\).)

        So far it is working. If I see another error, I'll post it here. Thanks for your assistance!

Share

Resources