18

I am trying to figure out a regular expression that matches a . (period). I looked for a formula but there was no formula that matches period.

12903,03930.
Brandon
  • 16,382
  • 12
  • 55
  • 88
user3466687
  • 219
  • 1
  • 2
  • 8
  • This is addressed in the [StackOverflow Regular Expression FAQ](http://stackoverflow.com/a/22944075/2736496) under "Other", about 1/2 to 2/3 down. Relevant answers: [What special characters must be escaped?](http://stackoverflow.com/q/399078), [`[.]`:literal dot character](http://stackoverflow.com/a/21929764) – aliteralmind Apr 09 '14 at 02:04
  • Thank you, I will check them out. – user3466687 Apr 09 '14 at 02:14

1 Answers1

30

You just need to escape the . as it's normally a meta character. The escape character is a backslash:

\.

E.g:

/[0-9]+\./

Will match a number followed by a period.

If you wanted to match the entire number except the period, you could do this:

/([0-9,]+)/

Here we use the range operator to select all numbers or a comma, 1 or more times.

Brandon
  • 16,382
  • 12
  • 55
  • 88