const string strRegex = @"(?<city_country>.+) (cca|ca.|ungefähr) (?<price>[\d.,]+) (eur)?";
searchQuery = RemoveSpacesFromString(searchQuery);
Regex regex = new Regex(strRegex, RegexOptions.IgnoreCase);
Match m = regex.Match(searchQuery);
ComplexAdvertismentsQuery query = new ComplexAdvertismentsQuery();
if (m.Success)
{
query.CityOrAreaName = m.Groups["city_country"].Value;
query.CountryName = m.Groups["city_country"].Value;
query.Price = Convert.ToDecimal(m.Groups["price"].Value);
}
else
return null;
ca. must be for example only 1 times but the word “Agadir ca. ca. 600 eur” is also correct even if “ca.” is 2 times. Why? i do not use + or ?
As with previous topic it gets into
city_countrygroup. Try to replace(?<city_country>.+)with(?<city_country>[^.]+). It will match everything except.. I guess yourcity_countrycouldn’t have dots inside?