Regular Expression Pattern for C# with matches

Posted by Sumit Gupta on Stack Overflow See other posts from Stack Overflow or by Sumit Gupta
Published on 2012-05-31T10:37:37Z Indexed on 2012/05/31 10:40 UTC
Read the original article Hit count: 224

Filed under:
|

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

  • 23,2 Hz
  • 24,4Hz
  • 25,0 Hzsadf
  • 26 Hz
  • 27Khz
  • 28hzzhzhzhdhdwe
  • 29
  • 30.4Hz
  • 31.8 Hz
  • 4343.34.234 Khz
  • 65SD

Further Explanation:

  1. System needs to work for US and Belgium Culture hence, 23.2 (US) = 23,2 (Be)
  2. I try to find a Digit, followed by either khz,mhz,hz or space or , or .
  3. If it is , or . then it should have another Digit followed by khz, mhz, hz

Any help is appericated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex