How to write regex which returns only “I”, followed by “J” or “V”, and then between 1 and 3 numbers?

Need to an expression that returns only things with an "I" followed by either a "J" or a "V" (No Quotes) and then a minimum of 1 number up to 3 numbers.

I J### I V### I J## I V## I J# I v#

Answers


Depends on your flavor

I(J|V)[0-9]{1,3}

Do you also need a space after an "I"?

I (J|V)[0-9]{1,3}

Your description does not match your example, and there are some idiomatic things that you'll need to take care of (case insensitivity, that depends on the regex engine)

I [JV]\d{1,3}

This will match

  • I J1
  • I J12
  • I J123
  • I V1
  • I V12
  • I V123

But WILL NOT MATCH

  • I 1
  • I 12
  • I 123

Need Your Help

Android: onListItemClick in Activity

java android eclipse lazylist

Previous time I asked a question here I learned a lot so I guess it's worth a shot to try it again.

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.