--As of January 5, 2015 4:38:03 PM -0800, John Hardin is alleged to have said:

On Mon, 5 Jan 2015, Bowie Bailey wrote:

On 1/5/2015 4:13 PM, John Hardin wrote:
 On Mon, 5 Jan 2015, Bowie Bailey wrote:

>  You can avoid having to escape the slash (/) by using a different
>  separator for the regex.  This can avoid "leaning toothpick
>  syndrome."
>
>  For example:
>    m#http://match/this/url/#

 Ouch. # won't work for that (in SA at least) as it comments out the
 rest of the RE.

Ack!  Forgot about that minor difference with SA.  # is my general go-to
character for that in normal Perl scripts.

This should illustrate the same point with the minor improvement of
actually  *working* in SA:
  m^http://match/this/url/^

I tend to avoid using symbols that are syntactically significant in REs
for that purpose. In your example, you can't then anchor the RE at the
beginning of the URL because ^ has been repurposed as the RE delimiter.

--As for the rest, it is mine.

Since we've already established this is Perl...

I like to use braces. Perl handles them (and brackets or parens) specially: Open with the opening brace and you close with the closing brace. I think Perl will parse for balance as well, but I haven't checked at the moment.

 m{http://match/this/url}

In general though I do tend to stick with slashes unless it's going to be a problem; it's just more common and easier for people to recognize.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

Reply via email to