Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
How to get the match for the following use cases from this regex pattern?

I have the Regex to match the following patterns,

Link to the Use case: https://regex101.com/r/wnp1k4/1

How can i get the match for the same by modifying the Regex? please help.

(?:^|(?<=[\D;a-zA-Z(),.:;?!"'`>]))(?!000|666|9)(?<![Oo][Rr][Dd][Ee][Rr].)(?<![Oo][Rr][Dd][Ee][Rr]..)(?<![Oo][Rr][Dd][Ee][Rr]...)(?<![Oo][Rr][Dd][Ee][Rr].[Nn][Uu][Mm][Bb][Ee][Rr].)(?<![Oo][Rr][Dd][Ee][Rr].[Nn][Uu][Mm][Bb][Ee][Rr]..)(?<![Oo][Rr][Dd][Ee][Rr].[Nn][Uu][Mm][Bb][Ee][Rr]...)(?<![Xx])\d{3}[ -.=\n\r]{0,10}(?!00)\d{2}[ -.=\n\r]{0,10}(?!0000)\d{4}(?:$|(?=[\Da-zA-Z(),.:;?!"'`<= ]))

Order numbers should not get detected if 'X or x' precedes the number. so this is working fine.

x123456789

X123456789

x123-456-789

X123-456-789

123-456-789

Need to modify the regex pattern to get the match for the list of ordernumbers written like below...along with the word (order number) should be case insensitive.

ordernumber123-456-789

order number123-456789

order number 123456789

123-456789

123456789

ordernumber-123456787

ordernumber - 123456789

ordernumber #123456789

ordernumber anysplcharacter123456789

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Converting my comment to answer so that solution is easy to find for future visitors.

You may use this regex:

(?<!\d)(?!000|666|9)(order\W?number)?\W*(?<!x)\d{3}[ .=-]{0,10}(?!000)\d{3}[ .=-]{0,10}(?!000)\d{3}

RegEx Demo

RegEx Details:

  • (?<!\d): Make sure that previous character is not a digit
  • (?!000|666|9): Make sure that we don't have 000 or 666 or 9 at the next position
  • (order\W?number)?: Match order and number optionally separated with a non-word character
  • \W*: Match 0 or more non-word characters
  • (?<!x): Make sure previous character is not x
  • \d{3}: Match 3 digits
  • [ .=-]{0,10}: Match 0 to 10 instances of given separators
  • (?!000): Make sure we don't have 000 at next position
  • \d{3}: Match 3 digits
  • [ .=-]{0,10}: Match 0 to 10 instances of given separators
  • (?!000): Make sure we don't have 000 at next position
  • \d{3}: Match 3 digits
about 4 years ago · Juan Pablo Isaza Denunciar

0

/((?<key>order\s*number).*)?(?<!x)(?<value>\d{9}|\d{3}-\d{6}|\d{3}-\d{3}-\d{3})/gim

const multilineSample = `x123456789
X123456789
x123-456-789
X123-456-789

123-456-789

ordernumber123-456-789
order number123-456789
order number 123456789

123-456789
123456789

ordernumber-x123456787

ordernumber-123456787
ordernumber - 123456789
ordernumber #123456789
ordernumber *anysplcharacter*123456789
ordernumber !@#$%^&123456789

ordernumber !@#$%^&x123456789`;

const regXOrderNumber =
  // see ... [https://regex101.com/r/wnp1k4/6]
  /((?<key>order\s*number).*)?(?<!x)(?<value>\d{9}|\d{3}-\d{6}|\d{3}-\d{3}-\d{3})/gim;

console.log(
  'all results each with its mapped named capture group ...',
  Array.from(
    multilineSample.matchAll(regXOrderNumber)
  )
  .map(({ groups }) => groups)
);
.as-console-wrapper { min-height: 100%!important; top: 0; }

about 4 years ago · Juan Pablo Isaza Denunciar

0

try this.

^([^x]|(order\s?number\s?)(\s?[-|#]?\s?))(anysplcharacter)?([\d-]+)$

Is there another case?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda