1
\p{N}[\p{N}.]*

It's used in a word counting algorithm but not sure if that's what it's doing, and whether or not its accurate.

1 Answers1

0

Looks like it matches unicode numbers kind of like \d[\d.]*. It does not look like a very good expression since it will match things like 1234 and 1..2..3.. but that depends on your data. I mean you may not have things like this in it.

\p{N} or \p{Number}: any kind of numeric character in any script.

Regular expression \p{L} and \p{N}

Community
  • 1
  • 1
jdb
  • 4,419
  • 21
  • 21
  • So this doesn't match words? It just matches numbers??!? –  Mar 08 '13 at 02:23
  • Like, if I matched it against "How now, brown cow", it couldn't be used to tell me that there are 4 words in the string? –  Mar 08 '13 at 02:23
  • It matches numbers `123` and `1.234455`. Things like that – jdb Mar 08 '13 at 02:24
  • If you match it agains "How now, brown cow" it will return false – jdb Mar 08 '13 at 02:26
  • Thanks again @jdb - almost there. Can you please see my original (edited) post? Another user mentioned that I might have posted some Ruby-specific escape sequences in my original post, so I deleted them out. Can you look at it and confirm that the original regex I posted doesn't change your opinion of what this regex does? Thanks again! –  Mar 08 '13 at 02:33
  • I have run `\p{N}[\p{N}.]*` in Java and it does exactly what I said. `"How now, brown cow".replaceAll("\\p{N}[\\p{N}.]*", "x");` prints `How now, brown cow`. And "123".replaceAll("\\p{N}[\\p{N}.]*", "x");` prints `x` – jdb Mar 08 '13 at 02:37