Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] PS: Regex searching ???

Expand Messages
  • Charles K. Clarkson
    ... How s about: Change all occurrences of * in $search to .*? s/ */.*?/g; Change all occurrences of ? to . tr/?/./g; This will allow some wildcard matching. ?
    Message 1 of 2 , Oct 1, 2001
    • 0 Attachment
      "Gordon Stewart" <Gordon.Stewart@...> wrote:


      :
      : If i put s*ta in the search field, i want to find an 's'
      : any number of characters and then a 'ta'.
      :
      : But it only brinf=gs up all those wityh 'ta'.
      :
      : If i put s+*ta (one or more 'S's - then any number of
      : characters & TA, it produces an error..
      :
      : what do put in the 'search' box to produce
      : "one or more 'S's - then any number of characters & TA"
      : (case INsensitive)
      :
      : OR - what can i put in my perl script to change the
      : 'search' value entered - from
      :
      : s*ta into (whatever) - To find an S, any number of
      : characters & then TA.
      :

      How's about:
      Change all occurrences of * in $search to .*?
      s/\*/.*?/g;

      Change all occurrences of ? to .
      tr/?/./g;


      This will allow some wildcard matching. ? allows a
      match on any one character. * allows multiple matches.
      MSDOS and *nix systems use these wildcards, so your
      users can rely on their current skills. The + wouldn't
      need changing, but is not as widely known as ? and *.
      You'll have to educate your users.

      The code below will make it easier to add more
      search characters as needed. The tr (translate)
      needs to come first:

      my $search = 's???t*r';
      for ($search) {
      tr/?/./; # ?
      s/\*/.*?/g; # *
      }
      print $search;


      HTH,
      Charles K. Clarkson
      Clarkson Energy Homes, Inc.


      Nobody owes anyone else a living.
    • Gordon Stewart
      ... It should be s+ta ); would circle be included in the search ? as far
      Message 2 of 2 , Oct 2, 2001
      • 0 Attachment
        >>> Jenda@... 10/02/01 10:56 >>>
        >
        It should be
        s+ta
        <

        Hmm - If i put ir+le in the search field, using

        @araa = grep(/$search/i, <INF>);

        would "circle" be included in the search ?

        as far as i see - Its not - only those with irle are being retrieved / got..

        not ir (any characters) & then le

        Ive placed a 'print' statement before & after the grep - & exited the programme - I use no other grepping / sorting..

        Even printing the source-data of @araa - after the grep..

        Curious ???

        G.
      Your message has been successfully submitted and would be delivered to recipients shortly.