Is this possible?
Is this possible?
Hello,
I would like to find text between both square and round brackets in the same document. I would then like to delete both sets of brackets but replace every trailing bracket with a semi-colon, then delete multiple entries of the same word and then copy the remaining text to the clipboard.
Is that doable? If so how?
Thanks in advance for your help
I would like to find text between both square and round brackets in the same document. I would then like to delete both sets of brackets but replace every trailing bracket with a semi-colon, then delete multiple entries of the same word and then copy the remaining text to the clipboard.
Is that doable? If so how?
Thanks in advance for your help
Re: Is this possible?
Hello MacH,
Anything is possible
I have a number of questions about what your are trying to do. It might help to explain what your file looks like and what you are trying to achieve.
Generally if you want to combine a set of editing steps into one "action" you will use what is called a macro. A macro is simply a file where each line constitutes one command. You can then "run" the macro, and all the editing steps will be carried out in order. Fortunately Nisus has some very powerful commands—in particular Find and Replace—that allow you to make the kind of changes you are looking for. Beyond the basics Nisus also has a macro language, which allows you to implement more sophisticated editing algorithms.
Your first step, finding and replacing text between parentheses/brackets is a common task, that has been discussed many times on this forum. See for example here. For this you can just use Powerfind, and the find expression discussed there. In the Replace box put the semicolon. As macro code this would like this:
The second task you describe sounds like you are trying to make a word list. Nisus should already come with a macro to do that in Macros > Document > Word List, which might do what you want, though it will put the result in a new document rather than on a clipboard.
If this is still not what you are looking for, let us know, and we can give other suggestions.
Anything is possible

I have a number of questions about what your are trying to do. It might help to explain what your file looks like and what you are trying to achieve.
Generally if you want to combine a set of editing steps into one "action" you will use what is called a macro. A macro is simply a file where each line constitutes one command. You can then "run" the macro, and all the editing steps will be carried out in order. Fortunately Nisus has some very powerful commands—in particular Find and Replace—that allow you to make the kind of changes you are looking for. Beyond the basics Nisus also has a macro language, which allows you to implement more sophisticated editing algorithms.
Your first step, finding and replacing text between parentheses/brackets is a common task, that has been discussed many times on this forum. See for example here. For this you can just use Powerfind, and the find expression discussed there. In the Replace box put the semicolon. As macro code this would like this:
Code: Select all
Find and Replace '\(.+?\)', ';', 'Ea'
Find and Replace '\[.+?\]', ';', 'Ea'
If this is still not what you are looking for, let us know, and we can give other suggestions.
philip
Re: Is this possible?
Hi, Thanks for taking the time to reply! I realise it is a basic request, but after spending a bit of time, this is what I came up with:
(?<=()[^\n\f]+(?=))|(?<=[Read )[^\n\f]+(?=])
It does the majority of what I would like but would like to refine it a bit more as I have to run this through 400+ PDF's and it will save a lot of time. I hadn't considered macros...
Thanks
(?<=()[^\n\f]+(?=))|(?<=[Read )[^\n\f]+(?=])
It does the majority of what I would like but would like to refine it a bit more as I have to run this through 400+ PDF's and it will save a lot of time. I hadn't considered macros...
Thanks
Re: Is this possible?
In essence, I would like to find text between brackets and then exclude certain words or phrases to then copy what's left...
Re: Is this possible?
Hello MacH,
Re-reading your initial question, I realize that I misunderstood what you were looking for. Extra sorry!
You also say your are working on PDFs. So these are not Nisus documents? And you have 400 of them? And you weren't considering a macro? Are you going open them one by one in Nisus?
Anyhow getting back to your original question. I realize now that you are trying to collect all and only the text inside parens and brackets without the parens/brackets. You seemed to want to collect them with semi-colon delimiters. (Is that crucial?) Does each of these 400 docs have many such bits? Are these bits in parens/brackets long or just single words? I'm asking this because then you say you want to "delete multiple entries of the same word". Are these "same words" instances of the bits in the parens/brackets, or are you talking about deleting "same words" within these bits? Your final step is putting the result on the clipboard. (Fine, but why? Why not just put them where they are needed?) So your final result will be that the clipboard contains a set of semi-colon delimited non-repetitive phrases. Ignoring the non-repetitive thing, here's a macro to do that.
Anyhow if you can explain better what you mean by the "exclude certain words or phrases" I can help you add that in, if you'd like. I could also help you write it so that it will process all 400 in one go if that's what you need…
No one said this was a basic request. Maybe me pointing you to past advice gave you that impression. Sorry!
Re-reading your initial question, I realize that I misunderstood what you were looking for. Extra sorry!
I'm confused about this. Does that expression work for you? It isn't a valid search expression. [Okay I see now that some backslashes have gone missing. Hey, you didn't explain about the "Read " bit either.]
You also say your are working on PDFs. So these are not Nisus documents? And you have 400 of them? And you weren't considering a macro? Are you going open them one by one in Nisus?
Anyhow getting back to your original question. I realize now that you are trying to collect all and only the text inside parens and brackets without the parens/brackets. You seemed to want to collect them with semi-colon delimiters. (Is that crucial?) Does each of these 400 docs have many such bits? Are these bits in parens/brackets long or just single words? I'm asking this because then you say you want to "delete multiple entries of the same word". Are these "same words" instances of the bits in the parens/brackets, or are you talking about deleting "same words" within these bits? Your final step is putting the result on the clipboard. (Fine, but why? Why not just put them where they are needed?) So your final result will be that the clipboard contains a set of semi-colon delimited non-repetitive phrases. Ignoring the non-repetitive thing, here's a macro to do that.
Anyhow if you can explain better what you mean by the "exclude certain words or phrases" I can help you add that in, if you'd like. I could also help you write it so that it will process all 400 in one go if that's what you need…
philip
Re: Is this possible?
Hi Philip,
I have been a Nisus user for many years but never ventured beyond word processing, as with any language it can be intimidating, so was embarrassed to ask. The files actually are in PDF and Word which I convert. I only need to do one at a time as they need to be studied, but as they are seminar papers, there is some text that refers to the length of time that each section took (5 min, 15 min), so its this text that I want excluded.
The Macro was excellent and far more efficient than what I had, which worked, but over several steps.
Thanks again for your trouble!
I have been a Nisus user for many years but never ventured beyond word processing, as with any language it can be intimidating, so was embarrassed to ask. The files actually are in PDF and Word which I convert. I only need to do one at a time as they need to be studied, but as they are seminar papers, there is some text that refers to the length of time that each section took (5 min, 15 min), so its this text that I want excluded.
The Macro was excellent and far more efficient than what I had, which worked, but over several steps.
Thanks again for your trouble!
Re: Is this possible?
Hello again MacH,
I am glad the macro worked for you. As far as the text bits you want removed; if you can describe the relevant patterns, or give samples of the relevant phrases, I'm sure that part could be added to the current macro.
As to the general question of writing macros: I am, as I'm sure many visitors to these fora can guess, a big believer in the power to use such automations to speed up and simplify one's work process. The Nisus macro language, especially since about NWP v.2.0 really makes it easy to solve the typical problems that arise for most writers. But it's still complex. And whether it's worth the time to learn how to do it, for most people, is a difficult question.
I am glad the macro worked for you. As far as the text bits you want removed; if you can describe the relevant patterns, or give samples of the relevant phrases, I'm sure that part could be added to the current macro.
As to the general question of writing macros: I am, as I'm sure many visitors to these fora can guess, a big believer in the power to use such automations to speed up and simplify one's work process. The Nisus macro language, especially since about NWP v.2.0 really makes it easy to solve the typical problems that arise for most writers. But it's still complex. And whether it's worth the time to learn how to do it, for most people, is a difficult question.
philip
Re: Is this possible?
Hi,
Thanks again for your interest and I agree, learning any language can make life very rewarding.
As to my needs, in each document I have timing indicators in parenthesis which I would like to exclude from the results found, so for example (5 min.)
The times are always different so no pattern, but are always in that format.
Thanks again for your help.
Thanks again for your interest and I agree, learning any language can make life very rewarding.
As to my needs, in each document I have timing indicators in parenthesis which I would like to exclude from the results found, so for example (5 min.)
The times are always different so no pattern, but are always in that format.
Thanks again for your help.
Re: Is this possible?
Your earlier example was (5min, 15min). Can a time parentheses have several times separated by comma-space like that?
The basic pattern for (5 min) etc. will be like this:
If multiple times are allowed, as described, it will be like this:
Obviously this could be built into the macro, but I'm still confused about something. You say the files contain seminar papers. Is the part in the parens/brackets the stuff you want to read or the stuff you want to exclude? From this I'm getting the impression that it's the distracting times that are in these parens/brackets. But if that's the case, why do you want them collected on the clipboard with semicolons? Wouldn't you want the stuff not in the parens/brackets collected in an easy to read format?
Or maybe some parens/brackets contain useful info and some contain times. And you would like only the ones that are not times collected on the clipboard?
Whichever it is this can all be done. You just have to let me know which it is.
When you try to automate something like this, you should always start by describing the initial state A and the desired state B. Then it's often easy to write a macro that will efficiently get you from A to B. Some people mistakenly start from the steps they perform manually and try to create a macro that way. This often gives very inefficient macros.
The basic pattern for (5 min) etc. will be like this:
Code: Select all
Find '\(\d+ min\)', 'Ea'
Code: Select all
Find '\(\d+ min(?:, \d+ min)*\)', 'Ea'
Or maybe some parens/brackets contain useful info and some contain times. And you would like only the ones that are not times collected on the clipboard?
Whichever it is this can all be done. You just have to let me know which it is.
When you try to automate something like this, you should always start by describing the initial state A and the desired state B. Then it's often easy to write a macro that will efficiently get you from A to B. Some people mistakenly start from the steps they perform manually and try to create a macro that way. This often gives very inefficient macros.
philip
Re: Is this possible?
Well, the timings in parenthesis are to be excluded from collection. The end result with semi colons as separators are perfect as I then collect them as is and enter them into another program. There is only ever one time, never two as I illustrated earlier.
Thanks
Thanks
Re: Is this possible?
Okay. Well you can try the following, and see if it excludes the right bits from your collection.
philip
Re: Is this possible?
Hi, I just added a fullstops after min. and it worked perfectly!
Thanks again for your help, its very kind of you, as it still seems a little complicated!
Thanks
Thanks again for your help, its very kind of you, as it still seems a little complicated!
Thanks