0

9.jul. 3 dni od 205,00 EUR

Is it possible with single regex (match opr split) get 205,00 number from string? It must be single regex and not 2 or 3 regex which give 205,00 as result.

string looks like:

 <option value="9.7.2010|3">9.jul. 3 dni od 205,00&nbsp;EUR <option value="23.7.2010|3">23.jul. 3 dni od 205,00&nbsp;EUR <option value="27.8.2010|3">27.avg. 3 dni od 205,00&nbsp;EUR <option value="10.9.2010|3">10.sep. 3 dni od 205,00&nbsp;EUR <option value="24.9.2010|3">24.sep. 3 dni od 205,00&nbsp;EUR <option value="29.10.2010|3">29.okt. 3 dni od 205,00&nbsp;EUR <option value="25.3.2011|3">25.mar. 3 dni od 205,00&nbsp;EUR <option value="15.4.2011|3">15.apr. 3 dni od 205,00&nbsp;EUR </select>
senzacionale
  • 20,448
  • 67
  • 204
  • 316

4 Answers4

1

Perhaps

(\d+,\d\d) EUR$

You didn't really specify what the subject looks like in general.

Artefacto
  • 96,375
  • 17
  • 202
  • 225
1

There are two possible issues here

The space

Is it a space (ASCII 32), or &nbsp;? Or perhaps it's just any \s character?


The match portion

I'm going to assume that it's just a regular space. If this is not the case, then substitute it in the following pattern.

To match only the numbers portion, you can use \d+,\d\d(?= EUR). This uses lookahead (?=___) so you only match the portion that you're interested in.

The other option is to match (\d+,\d\d) EUR and then extract Groups[1].

Related questions

References

Community
  • 1
  • 1
polygenelubricants
  • 376,812
  • 128
  • 561
  • 623
1

Your attempt of (\d+,\d\d) EUR (hopefully you weren't actually typing in &nbsp;) should work, but you have to access group 1 out of the result to get just what's in the parentheses. For example:

Regex regex = new Regex(@"(\d+,\d\d) EUR");
Match match = regex.Match("9.jul. 3 dni od 205,00 EUR");
string cashString = match.Groups[1].Value;
Jacob
  • 77,566
  • 24
  • 149
  • 228
1

The &nbsp; will most likely be converted to ASCII 160 (html decoded), which is not the same as space. Using \s+ will match no breaking spaces as well as normal space, tab and line feed/carriage return.

If it's not decoded then you should be able to use &nbsp; instead of \s+.

(\d+,\d+)\s+EUR
Mikael Svenson
  • 39,181
  • 7
  • 73
  • 79