Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
How to prevent the following regex from matching ellipses?

I'm using this regex:

(?<=[.?!])\.

To match the period that comes after the final punctuation in a sentence. Example:

Sentence.. (The second period will be matched.)

Sentence sentence?. (The period will be matched.)

Sentence sentence!. (The period will be matched.)

It's been working fine so far ... except for ellipsis:

Sentence sentence... (The last two periods will be matched.)

How to modify this regex so it doesn't match ellipsis ...?

Live regex: https://regexr.com/6hf3n

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As you already make use of a lookbehind, you might use:

(?<=[?!]|(?<!\.)\.(?!\.\.))\.

The pattern matches:

  • (?<= Positive lookbehind, assert what is to the left is
    • [?!] Match either ? or !
    • | Or
    • (?<!\.)\.(?!\.\.) A dot when there is no dot to the left, and not 2 dot to the right
  • ) Close lookbehind
  • \. Match a dot

See a regex demo.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!