Regular expression restricting unwanted ones as well

I had written a regular expression to not allow duplicate words similar to SU MOTO in a text area.The idea is to restrcit words that are similar as shown here

SU    MOTO
 SUMOTO 
'       SU          MOTO '

but now it is also restricting

'SUMOTO1' 
'4 SU MOTO'

which are considered to be valid and can be allowed.

The regex is

 String pat =   "\\bSU(\\s*\\b\\w*\\b\\s*){0,5}MOTO(\\s*\\b\\w*\\b\\s*){0,5}";

Please help

EDIT

invalid ones: spaces before or after the word SU MOTO like

'                   SU             MOTO'
SU                      MOTO

Following are valid ones

4 SU MOTO
SU88888MOTO
SUMOTO566

Answers


Are you looking for

^\\s*SU\\s*MOTO\\s*$

(If not, say what string it is matching/not matching)


Need Your Help

Using hg repository as web site

website mercurial tortoisehg

This is somewhat related to my security question here. Is it a bad idea to use an hg / mercurial repository for a live website? If so, why?

How to make an 2D ArrayList immutable?

java arraylist 2d wrapper immutability

In the project I am working on, I have a 2D ArrayList which represents some data:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.