Click here to Skip to main content
15,899,679 members

Comments by Kyle A.B. (Top 2 by date)

Kyle A.B. 30-Oct-13 9:08am View    
Excellent, this works exactly. Thanks for the help. The webpage you sent explained the rest of my question as well, my final will be something like this..
Negative Lookbehind followed by the Positive Lookbehind.
(?<!\d)...(?<=\d)

-Kyle
Kyle A.B. 11-Oct-13 23:53pm View    
I believe I might have solved this myself in a manner similar to the one you suggested. (Also of note, I figured out the third character can actually take a,b,y & z. So the new regex might look like this one:

[0-6]*[\d]\s*[A-HJ-NP-Xc-hj-np-z]\s*[A-HJ-NP-Za-hj-np-z]{2}\s*([\d]+\s+[\d]+|(\d{2}|\d{4}|\d{6}|\d{8}|\d{10}|\d{12}|\d{14}))

Break down:
[0-6]*
The first digit - can be 0 through 6 or non-existent

[\d]\s*
The second digit - any digit and an optional space

[A-HJ-NP-Xc-hj-np-z]\s*
The third character - A through Z excluding I & O and an optional space

[A-HJ-NP-Za-hj-np-z]{2}\s*
Fourth and Fifth characters: The third character - 2x A through Z excluding I & O and an optional space

([\d]+\s+[\d]+|(\d{2}|\d{4}|\d{6}|\d{8}|\d{10}|\d{12}|\d{14}))
Here's where it gets tricky, most of the time this matches an MGRS string fine but it will also match '13TEF 100100 5' as an MGRS so I think the below would be a better solution:
(([\d]{1}\s+[\d]{1}|[\d]{2}\s+[\d]{2}|[\d]{3}\s+[\d]{3}|[\d]{4}\s+[\d]{4}|[\d]{5}\s+[\d]{5}|[\d]{6}\s+[\d]{6}|[\d]{7}\s+[\d]{7}|)|(\d{2}|\d{4}|\d{6}|\d{8}|\d{10}|\d{12}|\d{14}))

What are your thoughts on performance with this expression? Or am I missing anything?