Regex Pattern

k005
Advisor
Advisor

Regex Pattern

k005
Advisor
Advisor

Hi All;

 

How can I get only the values after the last equals(=) from mixed Texts in this way?

The number of values taken in this example is: 8.

 

\b([\d+,.]+) -->I tried that, it didn't work.

 

 

beton = 125x2:250 = 250
= 20
beton : (125x2=250) = 250
= 85
= 15.20
=13.25
Kalıp : 100x2=200 + 150*2=300 = 500
100x2=200 + 200*2=400 = 600

0 Likes
Reply
Accepted solutions (1)
708 Views
2 Replies
Replies (2)

_gile
Mentor
Mentor
Accepted solution

Hi,

 

If you want to capture the last number in the string, you can use RegexOptions.RightToLeft

> var regex = new Regex(@"(-?\d+(?:\.\d+)?)", RegexOptions.RightToLeft);
> regex.Match("beton = 125x2:250 = 250 m³").Captures[0].Value
"250"
> regex.Match("beton : (125x2=250) = 250 m³").Captures[0].Value
"250"
> regex.Match("= 15.20").Captures[0].Value
"15.20"
> regex.Match("=13.25m²").Captures[0].Value
"13.25"
> regex.Match("Kalıp : 100x2=200 + 150*2=300 = 500").Captures[0].Value
"500"


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

k005
Advisor
Advisor

Hi

 

I keep these text values in a List, i.e. all lines of text. How should I arrange in this case?

 

I'll take the totals.

 

*******************************************************************

 

okay i did it. Thank you very much, sir.

0 Likes