Matching text question..

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default Matching text question..

    I'm having trouble matching only entire words.

    If I run a search against a large block of text for the word: or

    It will find 'or' in every word that contains it. ie; Word, Form, etc.

    I want to only find entire words.

    If I use the \s switch like this:

    $TextToConvert =~ s/\sor\s/$TextToReplaceFoundTextWith/ig

    It will not find the or if it is located at the beginning of a line, at
    the end of a line or it has any punctuation next to it.

    If I use the \W switch, the search will include and MarkUp Language Code and
    replace it.

    Can anyone give me idea?


    Thanks.
    --
    ....
    `·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney



    Rodney Guest

  2. Similar Questions and Discussions

    1. Text Matching
      Hi everyone. I am working with an Illustrator 9.0 drawing that was given to my, drawn by someone else. I'm just trying to do some updating to it....
    2. Input Text Matching Frustration
      Hi: I've got an input field named "9bField" in the property inspector, and a button to submit a user response with the following script on it: ...
    3. simple pattern matching question
      hi, I want to be able to see if a string of text contains one or more instances of the forward slash character(\) or the double quotation(")...
    4. Matching quoted text question...
      I'm trying to place HTML Tags around the contents of Quoted material. I'm using the following PERL code: $TextBlockToConvert =~ s/"(.+?)"/"<FONT...
    5. and/or matching question
      Hi, On a web form, I have two fields "US_State" and "Other_State". In my perl script I have.... &no_State unless $FORM{'US_State'}; How...
  3. #2

    Default Re: Matching text question..

    Thanks James!!!

    That did the trick!

    I spent the last 12 hours trying to figure that one out.

    :))

    --
    ....
    `·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney



    Rodney Guest

  4. #3

    Default Re: Matching text question..

    I'm trying to place HTML Tags around the contents of Quoted material.

    I'm using the following PERL code:
    $TextBlockToConvert =~ s/"(.+?)"/"<FONT Color=BLUE>\1<\/Font>"/g;



    Below, is an example of problem text this code chokes on.

    Example Text: msgStop("", "Invalid date")


    1. The 1st set of Quotes have no contents and so it is
    simply ignored.

    2. The code then finds the next set of Quotes... which is ", "
    NOTE: These Quotes do not belong to the same pair.
    The HTML formatting code is applied to the comma.

    3. Finally, the last set of Quotes are ignored because the
    code thinks there is only a single last Quote left.


    In this example (above), I would like the find only the last pair of quotes
    and substitute its contents with the same text, plus the HTML formatting
    code.



    Any help would be certainly appreciated.
    --
    ....
    `·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney


    Rodney Guest

  5. #4

    Default Re: Matching text question..


    "Rodney" <NoSpamPlease@bellsouth.net> wrote in message
    news:HtM6b.1970$66.1706@bignews5.bellsouth.net...
    > I'm trying to place HTML Tags around the contents of Quoted material.
    >
    > I'm using the following PERL code:
    It's not PERL code; it's Perl code.
    > $TextBlockToConvert =~ s/"(.+?)"/"<FONT Color=BLUE>\1<\/Font>"/g;
    >
    >
    >
    > Below, is an example of problem text this code chokes on.
    >
    > Example Text: msgStop("", "Invalid date")
    >
    Roll-your-own solutions to parsing HTML are not encouraged. Take this
    opportunity to learn about the CPAN modules which have been developed and
    fine-tuned for this purpose. One such module frequently cited on this list
    is HTML::Parser.



    James E Keenan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139