Reputation: 2192
I am working on project where I need to find Frequency from a given text. I wrote a Regular expression that try to detect frequency, however I am stuck with how C# handle it and how exactly I use it in my software
My regular experssion is (\d*)(([,\.]?\s*((k|m)?hz)*)|(\s*((k|m)?hz)*))$
And I am trying to find value from
Further Explanation:
Any help is appericated.
Upvotes: 0
Views: 253
Reputation: 2301
Running replace
(\d+(?:[.,]\d+)?)\s*([KkMm]?[Hh][Zz])
for ($1 $2)
gives
(23,2 Hz)
(24,4 Hz)
(25,0 Hz)sadf
(26 Hz)
(27 Khz)
(28 hz)zhzhzhdhdwe
29
(30.4 Hz)
(31.8 Hz)
4343.(34.234 Khz)
65SD
Any corrections to desired behavior?
upd: this is with negative lookbehind and word boundary:
(?<![.,0-9])(\d+(?:[.,]\d+)?)\s*([KkMm]?[Hh][Zz])\b
(23,2 Hz)
(24,4 Hz)
25,0 Hzsadf
(26 Hz)
(27 Khz)
28hzzhzhzhdhdwe
29
(30.4 Hz)
(31.8 Hz)
4343.34.234 Khz
65SD
Upvotes: 1