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})/


I ([a-zA-Z\d]{3} \d{6} \d{7})

Match group 1 would contain the three alphanumerics plus the numbers you already catch with your other regex.

EDIT: Does not work because the pattern described in the question does not reflect what the author meant in the first place. What really was meant was first clarified in the comments.


Need Your Help

Embed wiki content in a website

web embed wiki

I want to have a few of my webpages to be in wiki format. I tried using Moin moin, and embeded it on a webpage with html iframe tag. But it loads the entire wiki page with the header and footer. I ...

unable to git clone on remote vm

git

I am trying to git clone a repository on to my remote vm, and it doesn't work.