.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Regex Pattern

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
k005
674 Views, 2 Replies

Regex Pattern

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

2 REPLIES 2
Message 2 of 3
_gile
in reply to: k005

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

Message 3 of 3
k005
in reply to: _gile

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report