tags:

views:

59

answers:

4

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>
+1  A: 

Perhaps

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

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

Artefacto
i already try similar: (\d+,\d\d) EUR but not working. result is not 205,00
senzacionale
@senzacionale: what is the result? No match at all? Or `205,00 EUR`?
polygenelubricants
hi, no match at all with your regex type. I use (\d+,\d+)(?= EUR) ater yor help. Thx.
senzacionale
+1  A: 

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

polygenelubricants
(\d+,\d+)(?= EUR) is what i am looking for. Thx!
senzacionale
+1  A: 

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
thx will try it
senzacionale
+1  A: 

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