Locate Pattern the Letter I followed by a space then three alpha numerics followed by a space

Need to locate the following pattern:

The letter I followed by a space then three alpha numerics followed by a space

"I ALN " "I H21 " "I 31M "

these items are also followed by a lat/lon that is trapped by this expression:

Dim regex As New Regex("\d{6} \d{7}")

Can the expressions be combined to return a match that would look like:

"H21 ###### #######"

Thanks,

Dave

Answers


/I ([0-z]{3} \d{6} \d{7})/

I don't know VB, but that regex would work with say perl.

Update: Given the new string provided.. something like this may work (depending on responses to my questions)

/^[A-z] ([0-z]{3}) [A-z] [0-z]{3} L (\d{6} \d{7})/

Matches would then be joined (match 1 containing the AAA, match 2 containing the Lat/Long).

Update #2: From OP: No on the pattern. The only pattern is I AAA then on the same line the 4000931 0892006. Can you add an OR statement to an expression

You can add an OR, sort of, but I'm uncertain that this is really what you want? This new regex will match I, followed by a space, followed by 3 alpha numeric characters, and then "anything", and the lat/long. Note tho that if there's data in the file or whatever you're parsing that matches a line like that (in that it's "other" data, but follows a similar pattern), you'll probably catch that too.

/^I ([0-z]{3}) .* (\d{6} \d{7})/


Need Your Help

Call event every random number

ios cocos2d-iphone int

Im trying to work out how to do a event every random number. I am using the following to get a random number between 50 + 100

OnTouchEvent steals from OnClick

android

I implemented OnTouchEvent ( I need to react on Action.MOVE and Action.Up ) and OnClick, but it never enter in OnClick. OnTouch steals evemt. How to solve this ? I need on touch because Actoion.Up ...

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.