Grep Pattern, matching any two consecutive words having 3 to 8 chars each

U

User

Hi,

What is the grep pattern to match (in a one line phrase) at least two
consecutive words having min 3 to max 8 chars each (number of chars need NOT be
the same in the two words)?

I can't find the proper pattern for that. It needs to be done solely by the
regexp engine (no further Perl instruction other than to recuperate the words
from the submatches).

Anyone knows?

Thanks a lot,

Daniel M.
 
B

Bob Walton

User wrote:

....

What is the grep pattern to match (in a one line phrase) at least two
consecutive words having min 3 to max 8 chars each (number of chars need NOT be
the same in the two words)?

I can't find the proper pattern for that. It needs to be done solely by the
regexp engine (no further Perl instruction other than to recuperate the words
from the submatches). ....
Daniel M.

Maybe something like:

/(\w{3,8})\s+(\w{3,8})/

?
 
U

User

Maybe something like:
/(\w{3,8})\s+(\w{3,8})/

Thanks Bob.


I oversimplified my problem. My bad :-(

What if I want a match when from 2 to 6 consec words having min 3 to 8 chars?

Regards,

Daniel M.
 
B

Ben Morrow

Quoth "User said:
Thanks Bob.

I oversimplified my problem. My bad :-(

What if I want a match when from 2 to 6 consec words having min 3 to 8
chars?

This, particularly the 'must be a single regex' bit, smells of homework.
Nevertheless, try

/\w{3,8} (?: \s+ \w{3,8} ){1,5}/x

Now go read perldoc perlretut.

Ben
 
U

User

Ben,

Thanks very much. :)
This, particularly the 'must be a single regex' bit, smells of homework.

Nope. No homework (but not work either).
Just something I wanted to know how to do.
Nevertheless, try
/\w{3,8} (?: \s+ \w{3,8} ){1,5}/x

I _knew_ I'd get some great help here.
Now go read perldoc perlretut.

Thanks for the tip.

Regards,

Daniel M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top