2

I have this string :

Ümraniye Tapu Müdürlüğünde ve Ümraniye Belediyesi İmar Müdürlüğünde 20.08.2014 onay tarih ve 254 sayılı mimari projesi incelenmiştir.

I'm getting datetime : like this :

t = DateTime.Parse(Regex.Match(mimaristring, @"\d(\d+)[-.\/](\d+)[-.\/](\d+)").Value);

I'm trying to get 254 like this :

num = Regex.Match(mimaristring,  @"(?<!\d\.)\b\d+(?:/\d+)?\b(?!\.\d)").Value;

I can catch 254 or 123/456 but now I also need to catch 123-456. How can I catch that? Thanks.

jason
  • 6,569
  • 33
  • 106
  • 189

1 Answers1

2

Add a - and / to the character class [-/] that will match either a single - or a single /:

(?<!\d\.)\b\d+(?:[/-]\d+)?\b(?!\.\d)
                 ^^^^

See the regex demo

enter image description here

Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476