- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: regular expression equivalent to perl's '\b' t...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 02:49 AM
10-03-2003 02:49 AM
I'm trying to find a regular expression tag to match a single word, just like '\b' in perl, so that I can match, say, "good" not "goods".
BTW, grep -w seemed not exists on 11.0
thanks,
Gary
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 02:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 02:57 AM
10-03-2003 02:57 AM
Re: regular expression equivalent to perl's '\b' tag to match word
I also have the impression that \
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 02:58 AM
10-03-2003 02:58 AM
Re: regular expression equivalent to perl's '\b' tag to match word
I might, however be misinterpreting what you mean here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 02:59 AM
10-03-2003 02:59 AM
Re: regular expression equivalent to perl's '\b' tag to match word
You can look for whitespace...
--
#echo goods|grep -E good[[:space:]]
--
and you can look for end of line...
--
#echo goods|grep -E good$
--
and you can combine ...
--
#echo "1goods\n2good\n3good "|grep -E -e good$ -e good[[:space:]]
2good
3good
--
but it starts to get messy.
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 03:18 AM
10-03-2003 03:18 AM
Re: regular expression equivalent to perl's '\b' tag to match word
egrep '[[:space:]]good[[:space:].]|^good[[:space:].]|[[:space:]]good$' some_file
note the dot inside the [], it stands for period, just in case the word appears at the end of a sentence.
but that still doesn't apply to "sed", since it's extended regular expression, I still can not substitute "good" to "VERY GOOD" with "sed"
thanks,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 03:38 AM
10-03-2003 03:38 AM
Re: regular expression equivalent to perl's '\b' tag to match word
egrep '[^a-Z]good[^a-Z]' goodfile
I tried this with said but can't get it to work perhaps some better sed maestro can.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 04:07 AM
10-03-2003 04:07 AM
Re: regular expression equivalent to perl's '\b' tag to match word
---
your solution seems doesn't cover the case while the word is at the very begining or very end of a line (^word or word$)
---
and BTW, seemed that the range should be [A-z], not [a-Z](I got such error "egrep: Invalid range within [] expression." )
---
thanks,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2003 04:29 AM
10-03-2003 04:29 AM
Re: regular expression equivalent to perl's '\b' tag to match word
This one really does work :)
cat goodfile | perl -n -e 's/\bgood\b/VERY good/;print;'