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

151
Views
how to make the decorator in a regex pattern textbox unselectable?

Here is a screenshot of regextester.com:

screenshot

Users can only select the spaces between the preset pattern decorators, how to achieve this? I inspected the stylesheets, still have no clue.

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

0

You need to utilize contentEditable, here's a simplified recreate of regextester input:

document.querySelector('.editor').addEventListener('click', e => {
  e.currentTarget.querySelector('.input').focus();
});
.editor .input {
  outline: none;
}

.editor *:not(.input) {
  opacity: 0.5;
  user-select: none;
}
<div class="editor">
  <span>/</span>
  <span class="input" contentEditable="true"></span>
  <span>/g</span>
</div>


Using pseudo elements is also a good idea since there are natually unselectable:

document.querySelector('.editor').addEventListener('click', e => {
  e.currentTarget.querySelector('.input').focus();
});
.editor .input {
  outline: none;
}

.editor .input::before, .editor .input::after {
  opacity: 0.5;
}

.editor .input::before {
  content: '/';
}

.editor .input::after {
  content: '/g';
}
<div class="editor">
  <span class="input" contentEditable="true"> </span>
</div>

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!