Solved

exact word match

Posted on 2000-04-06
1
171 Views
Last Modified: 2010-05-18
if i have text and want to search through it for a word like this

 while( $text =~ /\s*([^.!?]*\Q$word\E[^.!?]*[.!?])/g ){    

this will, for instance, return
"this is a test"
if i search for "e"

how do i get it to just give me back when its a full word
ie
it will give back
"this e is a test"
if i search for "e"
0
Comment
Question by:boofulls
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2690185
/\s*([^.!?]*\b\Q$word\E\b[^.!?]*[.!?])/g
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl - Mawk 2 102
perl CPAN issue 3 117
Awk Question 2 129
Matching a random pattern with one common character 2 76
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question