R – Why would Textpad ask if you want to use POSIX regular expression syntax

posixregextextpadwindows

I need to separate out a bunch of image urls from a document in which the images are associated with names like this:

bellpepper = "http://images.com/bellpepper.jpg"
cabbage = "http://images.com/cabbage.jpg"
lettuce = "http://images.com/lettuce.jpg"
pumpkin = "http://images.com/pumpkin.jpg"

I want to remove all text except the URLs from the file by deleting the variable name, equals sign and double quotes so I have a new file that is just a list of URLs, one per line.

I've tried various ways of identifying the non-URL data using regular expressions in Textpad by checking the "Regular expression" checkbox in the Find dialog window but Textpad doesn't seem to like any of them.

Under

Configure->Preferences->Editor

there's an option:

"Use POSIX regular expression syntax"

As opposed to what?

Is it possible that my problems performing this regex operation have to do with some quirk of Textpad's implementation of regex?

Best Answer

The POSIX alternative is as opposed to the TextPad default. From the Search/Replace help doc:

TextPad's regular expressions are based on POSIX standard P1003.2, but the syntax can be that of POSIX, or UNIX extended regular expressions (the default).

to get the job done in TextPad, use the following:

Find in: ^[^"]*"\([^"]*\)"
Replace with: \1

edit:

to break the expression down:

^ - start of line
[^"]* - in a set the caret ^ is for negation, 
        so a greedy match of anything that is not a "
        in this case, everything up to the first quote
" - the first quote per line in your source text
\(...\) - puts together a group that can be referenced later
[^"]* - same explanation as above, this time matching the url in question
" - the last quote on the line

Also, looking through the help doc on Regex in TextPad, there is a chart of legal expressions listing both the 'Default' and the 'POSIX' versions side by side. The only difference seems to be the escaping of the Grouping parens () and the Occurance curlies {} in the Default and the lack of escaping in the POSIX version.

With that in mind, to get the job done in TextPad with the 'use POSIX regular expression syntax' option checked, swap out the above 'Find in' expression with the following:

Find in: ^[^"]*"([^"]*)"