Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.mac.system > #52683 > unrolled thread

Testing Regular Expression on OS-X

Started byJF Mezei <jfmezei.spamnot@vaxination.ca>
First post2013-11-26 02:26 -0500
Last post2013-11-27 16:17 -0500
Articles 16 — 9 participants

Back to article view | Back to comp.sys.mac.system


Contents

  Testing Regular Expression on OS-X JF Mezei <jfmezei.spamnot@vaxination.ca> - 2013-11-26 02:26 -0500
    Re: Testing Regular Expression on OS-X Sandman <mr@sandman.net> - 2013-11-26 09:19 +0000
      Re: Testing Regular Expression on OS-X JF Mezei <jfmezei.spamnot@vaxination.ca> - 2013-11-26 15:07 -0500
        Re: Testing Regular Expression on OS-X Richard Kettlewell <rjk@greenend.org.uk> - 2013-11-26 20:13 +0000
        Re: Testing Regular Expression on OS-X David Ritz <dritz@mindspring.com> - 2013-11-26 14:18 -0600
        Re: Testing Regular Expression on OS-X Sandman <mr@sandman.net> - 2013-11-26 21:25 +0000
    Re: Testing Regular Expression on OS-X Barry Margolin <barmar@alum.mit.edu> - 2013-11-26 10:43 -0500
      Re: Testing Regular Expression on OS-X Jolly Roger <jollyroger@pobox.com> - 2013-11-26 16:13 +0000
      Re: Testing Regular Expression on OS-X Sandman <mr@sandman.net> - 2013-11-26 21:19 +0000
    Re: Testing Regular Expression on OS-X Jolly Roger <jollyroger@pobox.com> - 2013-11-26 16:12 +0000
      Re: Testing Regular Expression on OS-X JF Mezei <jfmezei.spamnot@vaxination.ca> - 2013-11-26 15:13 -0500
        Re: Testing Regular Expression on OS-X Jolly Roger <jollyroger@pobox.com> - 2013-11-26 21:19 +0000
    Re: Testing Regular Expression on OS-X Lewis <g.kreme@gmail.com.dontsendmecopies> - 2013-11-26 22:22 +0000
      Re: Testing Regular Expression on OS-X Lewis <g.kreme@gmail.com.dontsendmecopies> - 2013-11-26 22:23 +0000
    Re: Testing Regular Expression on OS-X Martin Τrautmann <t-usenet@gmx.net> - 2013-11-27 07:42 +0000
    Re: Testing Regular Expression on OS-X Nelson <nelson@nowhere.com> - 2013-11-27 16:17 -0500

#52683 — Testing Regular Expression on OS-X

FromJF Mezei <jfmezei.spamnot@vaxination.ca>
Date2013-11-26 02:26 -0500
SubjectTesting Regular Expression on OS-X
Message-ID<52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com>
Is there an easy way to test a regular expression on OS-X ?

For instance, with the test such as:

/^Return-Path:.*onmicrosoft.com/

I'd like to make sure it catches

Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>

but not unwanted stuff.

(this is added to the header checks in postfix).  So I'd like some easy
way to test the regexp for syntax and see whether the match is made or not.

[toc] | [next] | [standalone]


#52685

FromSandman <mr@sandman.net>
Date2013-11-26 09:19 +0000
Message-ID<slrnl98pua.uhi.mr@irc.sandman.net>
In reply to#52683
In article <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com>, JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:

>  Is there an easy way to test a regular expression on OS-X ?
>
>  For instance, with the test such as:
>
>  /^Return-Path:.*onmicrosoft.com/
>
>  I'd like to make sure it catches
>
>  Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>
>
>  but not unwanted stuff.
>
>  (this is added to the header checks in postfix).  So I'd like some easy
>  way to test the regexp for syntax and see whether the match is made or not.

echo "Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>" | grep "^Return-Path:.*onmicrosoft.com"


--
Sandman[.net]

[toc] | [prev] | [next] | [standalone]


#52710

FromJF Mezei <jfmezei.spamnot@vaxination.ca>
Date2013-11-26 15:07 -0500
Message-ID<5294ff7a$0$9159$c3e8da3$9f400e27@news.astraweb.com>
In reply to#52685
On 13-11-26 04:19, Sandman wrote:
> echo "Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>" | grep "^Return-Path:.*onmicrosoft.com"


Thanks ! Simpler than I thought. Didn't realise grep supported regular
expressions.

[toc] | [prev] | [next] | [standalone]


#52711

FromRichard Kettlewell <rjk@greenend.org.uk>
Date2013-11-26 20:13 +0000
Message-ID<wwvzjoq7wha.fsf@sfere.anjou.terraraq.org.uk>
In reply to#52710
JF Mezei <jfmezei.spamnot@vaxination.ca> writes:
> On 13-11-26 04:19, Sandman wrote:
>> echo "Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>" | grep "^Return-Path:.*onmicrosoft.com"
>
> Thanks ! Simpler than I thought. Didn't realise grep supported regular
> expressions.

That’s what the ‘re’ in the middle stands for...

-- 
http://www.greenend.org.uk/rjk/

[toc] | [prev] | [next] | [standalone]


#52714

FromDavid Ritz <dritz@mindspring.com>
Date2013-11-26 14:18 -0600
Message-ID<alpine.OSX.2.11.1311261416530.22669@mako.ath.cx>
In reply to#52710
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday, 26 November 2013 15:07 -0500, 
 in article <5294ff7a$0$9159$c3e8da3$9f400e27@news.astraweb.com>, 
 JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:

> On 13-11-26 04:19, Sandman wrote:

>> echo "Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>" | grep "^Return-Path:.*onmicrosoft.com"

> Thanks ! Simpler than I thought. Didn't realise grep supported 
> regular expressions.


grep:

    ORIGIN from the initial letters of global(ly) search regular 
    expression print.

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (Darwin)
Comment: Public Keys: <http://dritz.home.mindspring.com/keys.txt>

iEYEARECAAYFAlKVAi0ACgkQUrwpmRoS3uvqKgCfRH2G9EkCkO2BH6ym0+wkG232
0C8AoMhU1TGaeNa5mp9b+V0G2Y/tFN/c
=ZJ92
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#52718

FromSandman <mr@sandman.net>
Date2013-11-26 21:25 +0000
Message-ID<slrnl9a4gq.eo.mr@irc.sandman.net>
In reply to#52710
In article <5294ff7a$0$9159$c3e8da3$9f400e27@news.astraweb.com>, JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:

> > echo "Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>" | grep "^Return-Path:.*onmicrosoft.com"
>
>  Thanks ! Simpler than I thought. Didn't realise grep supported regular
>  expressions.

Be aware though, that grep uses BRE (Basic Regular Expressions) and 
whatever application you're implementing the RE in may use another 
standard, like ERE (Extended RE) which is more powerful or PCRE (Perl 
Compatible RE) that are even more powerful.


--
Sandman[.net]

[toc] | [prev] | [next] | [standalone]


#52691

FromBarry Margolin <barmar@alum.mit.edu>
Date2013-11-26 10:43 -0500
Message-ID<barmar-D8A9AA.10432926112013@news.eternal-september.org>
In reply to#52683
In article <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com>,
 JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:

> Is there an easy way to test a regular expression on OS-X ?

What does this mean? There's no single OS-X regular expression 
processor. Different applications use different regexp engines. So you 
need to test the specific application.

> 
> For instance, with the test such as:
> 
> /^Return-Path:.*onmicrosoft.com/
> 
> I'd like to make sure it catches
> 
> Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>
> 
> but not unwanted stuff.
> 
> (this is added to the header checks in postfix).  So I'd like some easy
> way to test the regexp for syntax and see whether the match is made or not.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

[toc] | [prev] | [next] | [standalone]


#52698

FromJolly Roger <jollyroger@pobox.com>
Date2013-11-26 16:13 +0000
Message-ID<bfjvm1FduirU3@mid.individual.net>
In reply to#52691
On 2013-11-26, Barry Margolin <barmar@alum.mit.edu> wrote:
> In article <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com>,
>  JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
>
>> Is there an easy way to test a regular expression on OS-X ?
>
> What does this mean? There's no single OS-X regular expression 
> processor. Different applications use different regexp engines. So you 
> need to test the specific application.
 
TextWrangler covers most of those bases fairly well.

-- 
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

[toc] | [prev] | [next] | [standalone]


#52717

FromSandman <mr@sandman.net>
Date2013-11-26 21:19 +0000
Message-ID<slrnl9a45d.eo.mr@irc.sandman.net>
In reply to#52691
In article <barmar-D8A9AA.10432926112013@news.eternal-september.org>, Barry Margolin <barmar@alum.mit.edu> wrote:

> > Is there an easy way to test a regular expression on OS-X ?
>
>  What does this mean? There's no single OS-X regular expression
>  processor. Different applications use different regexp engines. So you
>  need to test the specific application.

Well, his test case used a very simple RE, so most engines would get it 
correctly, if not all. 


--
Sandman[.net]

[toc] | [prev] | [next] | [standalone]


#52697

FromJolly Roger <jollyroger@pobox.com>
Date2013-11-26 16:12 +0000
Message-ID<bfjvk9FduirU2@mid.individual.net>
In reply to#52683
On 2013-11-26, JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> Is there an easy way to test a regular expression on OS-X ?
>
> For instance, with the test such as:
>
> /^Return-Path:.*onmicrosoft.com/
>
> I'd like to make sure it catches
>
> Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>
>
> but not unwanted stuff.
>
> (this is added to the header checks in postfix).  So I'd like some easy
> way to test the regexp for syntax and see whether the match is made or not.

I usually end up using TextWrangler for that.

-- 
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

[toc] | [prev] | [next] | [standalone]


#52712

FromJF Mezei <jfmezei.spamnot@vaxination.ca>
Date2013-11-26 15:13 -0500
Message-ID<52950105$0$9159$c3e8da3$9f400e27@news.astraweb.com>
In reply to#52697
On 13-11-26 11:12, Jolly Roger wrote:

> I usually end up using TextWrangler for that.

Another good suggestion. Hadn't realised that clicking on the "grep"
option for a find allows regular expressions. Even detects the special
characters in the find string. This is perhaps even better than the echo
option sicne I can take full header of a spam message and make various
tests.

[toc] | [prev] | [next] | [standalone]


#52716

FromJolly Roger <jollyroger@pobox.com>
Date2013-11-26 21:19 +0000
Message-ID<bfkhisFhuccU1@mid.individual.net>
In reply to#52712
On 2013-11-26, JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> On 13-11-26 11:12, Jolly Roger wrote:
>
>> I usually end up using TextWrangler for that.
>
> Another good suggestion. Hadn't realised that clicking on the "grep"
> option for a find allows regular expressions. Even detects the special
> characters in the find string. This is perhaps even better than the echo
> option sicne I can take full header of a spam message and make various
> tests.

Yeah. I find myself in TW so often, and the regex support is so good,nd
you can shove whatever content you want into the document to test
multiple use cases and so on. It's handy.

As others have mentioned, not all applications support regex in the same
manner. In those cases, you'll have to edit the expression to use
alternative methods.

-- 
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

[toc] | [prev] | [next] | [standalone]


#52720

FromLewis <g.kreme@gmail.com.dontsendmecopies>
Date2013-11-26 22:22 +0000
Message-ID<slrnl9a7pb.qc5.g.kreme@mbp55.local>
In reply to#52683
In message <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com> 
  JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> Is there an easy way to test a regular expression on OS-X ?

You can test it in Terminal, BBEdit, TextWrangler, and there's even a
dashboard widget, as I recall. Various other editors also have POSIX
regex support.

-- 
In the end we will not remember the words of our enemies, but the
silence of our friends. -Martin Luther King, Jr

[toc] | [prev] | [next] | [standalone]


#52722

FromLewis <g.kreme@gmail.com.dontsendmecopies>
Date2013-11-26 22:23 +0000
Message-ID<slrnl9a7rr.qc5.g.kreme@mbp55.local>
In reply to#52720
In message <slrnl9a7pb.qc5.g.kreme@mbp55.local> 
  Lewis <g.kreme@gmail.com.dontsendmecopies> wrote:
> In message <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com> 
>   JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
>> Is there an easy way to test a regular expression on OS-X ?

> You can test it in Terminal, BBEdit, TextWrangler, and there's even a
> dashboard widget, as I recall. Various other editors also have POSIX
> regex support.

s/POSIX/PCRE/

-- 
"You're an elf and you're going to wear panties like an elf."

[toc] | [prev] | [next] | [standalone]


#52742

FromMartin Τrautmann <t-usenet@gmx.net>
Date2013-11-27 07:42 +0000
Message-ID<slrnl9b8jd.fr8.t-usenet@ID-685.user.individual.de>
In reply to#52683
On Tue, 26 Nov 2013 02:26:46 -0500, JF Mezei wrote:
>  Is there an easy way to test a regular expression on OS-X ?

No.


There are many tools on OS-X which do support regular expressions: most
of them within the terminal (slrn, vi, grep etc.). There are some
programs with gui (TextWrangler, OpenOffice/LibreOffice etc.).

But how does this help to know whether the certain application you think
about does support the same subset of regular expressions?

What you think about should be part of every basic subset, suitable for
grep, perl -e etc. Personally, I had some problems with extended
expressions such as \d.

- Martin

[toc] | [prev] | [next] | [standalone]


#52759

FromNelson <nelson@nowhere.com>
Date2013-11-27 16:17 -0500
Message-ID<0001HW.CEBBCB9302C6527EB02919BF@news.astraweb.com>
In reply to#52683
On Tue, 26 Nov 2013 02:26:46 -0500, JF Mezei wrote
(in article <52944d38$0$17083$c3e8da3$40d4fd75@news.astraweb.com>):

> Is there an easy way to test a regular expression on OS-X ?
> 
> For instance, with the test such as:
> 
> /^Return-Path:.*onmicrosoft.com/
> 
> I'd like to make sure it catches
> 
> Return-Path: <AG02@uknationallottyboard.onmicrosoft.com>
> 
> but not unwanted stuff.
> 
> (this is added to the header checks in postfix).  So I'd like some easy
> way to test the regexp for syntax and see whether the match is made or not.

There are several nice online tools.  Google "regular expression 
tester".

-- 
Nelson

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.mac.system


csiph-web