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