LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-24-2010, 12:44 PM   #1
logar0
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Rep: Reputation: 0
Question Help with sed regex to match words via a pattern.


Hello everyone!

I have some lines of text and I want to detect words that meet some criteria with sed.

E.g. The line "tetris cat dog test cactus stereotype"

I want to detect the word that contains two (2) ore more t letters. That mean the words tetris, test and stereotype.

The following regex doesn't do the job because it can;t distinguish words very well.

/.*t.*t.*//

I thinks I have ti incorporate something like [^ ] in the regex but I wasn't successful...

Any help?
 
Old 10-24-2010, 12:59 PM   #2
codegenie
LQ Newbie
 
Registered: Oct 2010
Distribution: Redhat
Posts: 24

Rep: Reputation: -3
I am not sure but why dont you try this::
a [a-zA-z0-9]
%%
{a}*[t]{a}*[t]{a}* {printf("valid ");}
%%
 
Old 10-24-2010, 04:14 PM   #3
logar0
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
No, unfortunately it doesn't work. Anyone else?
 
Old 10-24-2010, 05:33 PM   #4
logar0
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Ok, I found the regex.

[ ]*[^ ]*t[^ ]*t[^ ]*
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use sed to delete all lines before the first match of a pattern? C_Blade Linux - Newbie 9 05-01-2010 05:18 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
simple pattern match with awk, sed alenD Linux - Newbie 10 03-10-2008 03:31 PM
sed display line after pattern match inonzi_prowler Linux - Software 3 02-19-2007 02:47 PM
how to use the sed w option to redirect pattern match to file nickleus Linux - General 11 04-18-2006 09:34 AM


All times are GMT -5. The time now is 12:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration