Home > Net >  Need regular expression for first number in string
Need regular expression for first number in string

Time:12-16

i need to exclude the first number of the following string: DE 199,00;AT 219,99; IT 399,00 In this case i need the 199,00

DE 79,00;AT 99,99; IT 119,00 And here i need 79,00

I have no plan of regex :-( So i hope that i get help here. Thank you

With the following i get the first "Group" eg DE 199,00

^[^;]*

But i need just the number

CodePudding user response:

To extract "199,00" from the string "DE 199,00;AT 219,99; IT 399,00" you'd use the regular expression

[0-9,] 

CodePudding user response:

^[^;]* -This regex matches any string that does not contain a semicolon (;) including letters.

\d (?:,\d{2}) -This regex adheres to a pattern that matches any number of digits (1 or more), followed by an optional group of a comma and two digits.

Edit: Trying to understand your comment on the answer above. So what you want to do is to find any group beginning with the letters DE followed by a whitespace, string, and semicolon => /DE\s\D ;/; This will give you a group that relates to your DE 199,00; and after you have this you can extract the number.

  • Related