0

I need to scan a few thousand documents in Mongo and find records for which a field has the following substrings:

  1. any text followed by 2 dots. For example: Co..
  2. any text that contains a '.' in the middle (i.e. not first and not last) of a string

Also, for either case is there a way to automatically remove the extraneous '.'?

zevij
  • 2,416
  • 1
  • 23
  • 32

1 Answers1

1

This is the regular expression you're looking for:

/(.+\..+)|(\.\.$)/

You can check regex101 for thorough explaination.

Also, for either case is there a way to automatically remove the extraneous '.'?

You'll need to iterate through found documents, alter them manually and later save. For a more thorough explaination please see this answer

Community
  • 1
  • 1
malarzm
  • 2,831
  • 2
  • 15
  • 25