[rt-users] help in creating Scrips

Matthew Seaman matthew.seaman at thebunker.net
Thu Jun 11 03:37:18 EDT 2009


rmp dmd wrote:
> Thank you very much Drew. Your link definitely is a big help.
> 
> The syntax are quite different with the programming applications that I am
> familiar (very few though).  It's very hard modifying it for our specific
> use. Is there a guide about this?

These are perl regular expressions.  See
http://perldoc.perl.org/perlre.html for details, but the following means...

> For starters, someone kindly teach me the meaning of \w+) - (.*) (\w+) on

> Subject =~ /\*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ )

             /   <-- start of matching operator
               \*\*    <-- match two * characters literally.  Without
                           the \ escape, * is an operator that means
                           'zero or more times'
                   PROBLEM <-- match literal text
                           (  <-- start of capture group
                             \w+  <-- one or more 'word' characters
                                ) <-- close capture group
                                  -  <-- match literal text
                                     (.*)   <-- capture group of zero or
                                                more of any sequence of
                                                characters. '.' is the
                                                wildcard character
                                            <-- match literal ' ' char
                                         (\w+) <-- capture group of one
                                                   or more word chars.
                                                 <-- another space
                                                \*\*  <-- two more stars
                                                    / <-- end of match
                                                          expression

  Note that all the white space in the expression also has to match
  literally.  In summary this captures 3 strings out of the matched
  text: the first word after '**  PROBLEM ', Everything in the middle
  and then the last word at the end before ' **'.

> 
> and *(\d\d\d\d\d\d?) on
> 
> $subject =~ /\D*(\d\d\d\d\d\d?)\D*/)

   \D is a non-digit character.  \d is a digit, so this matches any
   number of non-digit characters \D*, then it captures 5 digits
   \d\d\d\d\d and possibly also a 6th digit \d? (? is an operator
   meaning 0 or 1 times) followed by any number of non-digit characters
   \D* again.  You could write the capture expression bit as (\d{5,6})
   meaning 'from 5 to 6 digits'

	Cheers,

	Matthew

-- 
Dr Matthew Seaman                        The Bunker, Ash Radar Station
PGP: 0x60AE908C on servers               Marshborough Rd
Tel: +44 1304 814890                     Sandwich
Fax: +44 1304 814899                     Kent, CT13 0PL, UK

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090611/8ebac703/attachment.sig>


More information about the rt-users mailing list