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

Re: [PBML] searching for user entered string

Expand Messages
  • Hudson T Clark
    Well what are you comparing them to? what are you searching in? you are searching for your name: my $name = wayne clements ; So you need to split it up... my
    Message 1 of 3 , May 2 12:57 AM
    • 0 Attachment
      Well what are you comparing them to? what are you searching in? you are
      searching for your name:

      my $name = 'wayne clements';

      So you need to split it up...

      my @tmp = split / /, $name;

      Now @tmp should look like this:

      $tmp[0] = 'wayne';
      $tmp[1] = 'clements';

      And now the regex part, I don't understand what you want. Do you want to
      have regex return true if the word 'wayne' and 'clements' is anywhere in
      the file and any number of times? Do you want it to ONLY be true if each
      word appears ONLY once? You should check out perlre it has information on
      the perl regex but thats what you are going to be doing afte rwhat I show
      above... I just am not clear what regex you need. =P

      Plus go read the perlre page it will help you understand and you can
      figure this out on your own.

      [Non-text portions of this message have been removed]
    • diheptal
      hi, i want to search a file for a user entered string from STDIN, perhaps a first name and a second name. i only want the exact string entered and only one
      Message 2 of 3 , May 2 7:37 AM
      • 0 Attachment
        hi,

        i want to search a file for a user entered string from STDIN,
        perhaps a first name and a second name.

        i only want the exact string entered and only one occurrence of
        each word.

        so if i entered my name ['wayne clements', separated by white space],
        i want perl to find these two words.

        [after this i intend to do some substitutions, but forget that for
        now].

        so far, all i get is every occurrence of each letter entered.
        NOT what is wanted.

        any ideas will be gratefully received.


        wayne
      • James 'Chip' Kaufman
        ... Did you notice you forgot to include sample code? -- James Chip Kaufman jkaufman@wamnet.com PGP key: 697D43DE
        Message 3 of 3 , May 2 9:21 AM
        • 0 Attachment
          On Friday 02 May 2003 09:37, diheptal wrote:
          > hi,
          >
          > i want to search a file for a user entered string from STDIN,
          > perhaps a first name and a second name.
          >
          > i only want the exact string entered and only one occurrence of
          > each word.
          >
          > so if i entered my name ['wayne clements', separated by white space],
          > i want perl to find these two words.
          >
          > [after this i intend to do some substitutions, but forget that for
          > now].
          >
          > so far, all i get is every occurrence of each letter entered.
          > NOT what is wanted.
          >
          > any ideas will be gratefully received.
          >
          >
          > wayne
          >

          Did you notice you forgot to include sample code?

          --
          James 'Chip' Kaufman
          jkaufman@...
          PGP key: 697D43DE
        Your message has been successfully submitted and would be delivered to recipients shortly.