View Single Post
Old 07-01-2014, 02:15 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,614
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I think you may be a little misguided about what you can actually accomplish with text editors and their Search & Replace features (regex or otherwise).

You can find a pattern in a document (just like Notepad++ is dutifully doing for you), and step through them one at a time. Once found, you can replace that pattern with something else (sometimes using complicated captures from the original pattern-match). Then you can move on to the next occurrence of the pattern and replace IT with something (or skip it and move on to the next). Or you can replace all occurrences of the matched pattern in one fell swoop.

What you cannot do is extract all occurrences of a particular pattern--effectively getting rid of everything else. For that you would probably need to script a solution to extract the info (quite possibly using that scripting language's regex capabilities) that you want.

As far as your original regular expression to find the pieces you want: (judging by the limited amount of data I can see) I would think something like
Code:
/works/\d+
would do the trick.

I would change your second expression (the one you were using in OpenOffice) to:
Code:
/works/[0-9]+
(which for all practical purposes is the exact same expression as the first one: I don't know why the '\d' shortcut wouldn't work for you in OpenOffice--I don't really use it myself)

You were getting bit by regex's greediness in your expressions. Not sure how (or if) you can control Notepad++ or OpenOffice's greedy/non-greedy behavior. I tend to build expressions (wherever possible) that don't rely on manipulating the greedy/non-greedy behavior.

Last edited by DiapDealer; 07-01-2014 at 02:40 PM.
DiapDealer is online now   Reply With Quote