Jan 29, 2017 07:37 PM
(This post was last modified: Jan 29, 2017 07:50 PM by Priology.)
Having a bit of trouble matching 2 patterns.
Here is the current pattern it is matching.
public static string pattern = @"EUR \d{2,3}\,\d{2}";
If anyone can help me, I would appreciate it a lot!
DO NOT DEAL WITH THIS MEMBER
What pattern is it matching? Or am I missing something?
(Jan 29, 2017 07:47 PM)Annabelle Lee Wrote: What pattern is it matching? Or am I missing something?
Fuck I'm stupid. I've updated the OP.
DO NOT DEAL WITH THIS MEMBER
(Jan 29, 2017 07:50 PM)Priology Wrote: Fuck I'm stupid. I've updated the OP.
I meant that's the regex, but what are you trying to match it against? Sample text?
Your pattern looks fine but if you want to capture the match you must mark a group: EUR (\d{2,3}\,\d{2})
(Jan 30, 2017 04:57 AM)Owl Wrote: Your pattern looks fine but if you want to capture the match you must mark a group: EUR (\d{2,3}\,\d{2})
He wants both tho?
wouldent it be
Code EUR (\d{2,3})\,(\d{2})
Lotta blood to let, peace to make, give a fuk about a check
(Jan 30, 2017 05:31 AM)BahNahNah Wrote: He wants both tho?
wouldent it be
Code EUR (\d{2,3})\,(\d{2})
I would say this is correct, but why isn't he parsing it as a double to easily use it to round/cut down to x decimal places...
Mmh, strange either way.
Jan 30, 2017 08:40 AM
(This post was last modified: Jan 30, 2017 08:52 AM by GuRuHaX.)
(Jan 29, 2017 07:37 PM)Priology Wrote: Having a bit of trouble matching 2 patterns.
Here is the current pattern it is matching.
public static string pattern = @"EUR \d{2,3}\,\d{2}";
If anyone can help me, I would appreciate it a lot!
On the side, why are you using Regex in the first place ?
Are you not just trying to see if its a valid Euro amount aka a decimal one or looking for the string "Eur" and the format ?
Regex is more heavy than a 'TryParse' & Contains("Eur").
EDIT:
To be more complete here are samples on how you could do it ( assuming im not mistaking on what you want to achieve ofc)
Get the current threads UI culture and display its currency (USD, EUR, ...)
PHP Code
<?php RegionInfo ri = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); Console.WriteLine(ri.ISOCurrencySymbol);
Same as above
PHP Code
<?php string ci = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; Console.WriteLine(ri.ISOCurrencySymbol);
Try parse your value to a decimal one
PHP Code
<?php // check if "input" contains "Eur" before trying to parse it. string input; decimal output; if (decimal.TryParse(input, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, CultureInfo.CurrentCulture, out output)) { // continue here }
🤝
(Jan 30, 2017 05:31 AM)BahNahNah Wrote: He wants both tho?
wouldent it be
Code EUR (\d{2,3})\,(\d{2})
As LaPanthere said, I also found it strange to capture the decimal's sides individually. He could also mean there are 2 potential matches.
If that is not the case then yes it would be
(Jan 30, 2017 04:57 AM)Owl Wrote: Your pattern looks fine but if you want to capture the match you must mark a group: EUR (\d{2,3}\,\d{2})
(Jan 30, 2017 05:31 AM)BahNahNah Wrote: He wants both tho?
wouldent it be
Code EUR (\d{2,3})\,(\d{2})
(Jan 30, 2017 06:37 AM)Cecilia Wrote: I would say this is correct, but why isn't he parsing it as a double to easily use it to round/cut down to x decimal places...
Mmh, strange either way.
(Jan 30, 2017 09:01 AM)Owl Wrote: As LaPanthere said, I also found it strange to capture the decimal's sides individually. He could also mean there are 2 potential matches.
If that is not the case then yes it would be
I'm not experienced with C#, I apologise.
I'm trying to scrape prices from a website,
the format is like this:
"EUR 00,00" || "EUR 000,00" || "EUR 0.000,00"
However, I'm also trying to scrape the names of the items, so I need to match other strings.
|