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

186
Vistas
How to split by nonescaped dot and by ignoring double blackslash?

I need to split data by dot. And I have escaped dot(.), that I should ignore. Also I should ignore escaped backslash too (\). For example,

data1\\.d\\\\\.ata2\\\\.da\.ta3.data4

This string should be splitted to for substrings like as

data1\\
d\\\\\.ata2\\\\
da\.ta3
data4

I cannot to create regex for that. Do you know, it is possible? I tried to use following:

(?<!\\((\\\\){2,}))\\. - not working

I can create following regex if escaped slash defined only one time:

"((?<!\\\\)\\.)|((?=([^\\\\]*((\\\\\\\\)+[^\\\\]*)))\\.)";

For example data1\\.d\.ata2.da\.ta3.data4 splitted correctly:

data1\\
d\.ata2
da\.ta3
data4 

But I cannot detect backslash definition even number times. Can you help me, please? Thank you!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You may extract these strings using

(?s)(?:[^\\.]|\\.)+

See the regex demo. Details:

  • (?s) - enable the Pattern.DOTALL flag so that . could match across lines
  • (?:[^\\.]|\\.)+ - one or more occurrences of any char other than \ and ., or a \ followed with any char.

See a Java demo:

String line = "data1\\\\.d\\.ata2.da\\.ta3.data4";
Pattern p = Pattern.compile("(?s)(?:[^\\\\.]|\\\\.)+");
Matcher m = p.matcher(line);
List<String> res = new ArrayList<>();
while(m.find()) {
    res.add(m.group());
}
System.out.println(res);
// => [data1\\, d\.ata2, da\.ta3, data4]
over 4 years ago · Santiago Trujillo Denunciar

0

You may use this regex to get your matches:

(?=[^.])[^.\\]*(?:\\.[^.\\]*)*(?=\.|$)

RegEx Demo

RegEx Demo:

  • (?=[^.]): Make sure there is non-dot character ahead
  • [^.\\]*: Match 0+ of any character that is not a . not a \
  • (?:\\.[^.\\]*)*: A non-capture group that matches an backslash followed by an escaped character and that should be followed by 0 or more of any character that is not a . not a \. Match 0 or more of this group
  • (?=\.|$): Make sure we have a dot or end of line ahead
over 4 years ago · Santiago Trujillo 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