tags:

views:

47

answers:

3

I have a string with the following information.

Obabikon, ON 49°10′N 94°10’W 2278 km N69°W

I have a regex search as follows:

String LongPattern = @"(~)?([0-9\?])+°([0-9\?])*′[EWO]";
return FindPattern(source, LongPattern);

It should be finding the <94°10’W> But is it not. This regex is working for the rest of my data with out any problems.

Any clues?

+3  A: 

You've got two different kinds of apostrophy involved. Compare these:

49°10′N
94°10’W

If you want to be able to cope with either, change your regex to:

"(~)?([0-9\?])+°([0-9\?])*[′’][EWO]"

Alternatively, fix your input data :)

Jon Skeet
It is working now.
Arnej65
+2  A: 

The quotes are different. Your subject string has ’, while your regexp has '. It's a tiny difference, but they're different characters...

Matti Virkkunen
Thanks. I knew that it was something small.
Arnej65
A: 

There is more than one symbol here for minutes. Even within your sample string, the minutes portions of the latitude and longitude are different symbols. It looks like the symbol in your regex is the same as the one in the latitude, which is why it doesn't match the longitude.

In your longitude you have

In your regex you have

AakashM