En cada linea, ¿cómo eliminar todo lo anterior a la aparición de la primera barra?
-
Hola,
quisiera conseguir eliminar todo lo anterior a la aparición de la primera barra de cada línea, con la posibilidad de eliminar la barra o no eliminarla.
P.ej:
Agradeceria ayuda
Disculpen si es una pregunta absurda, soy nuevo en esto.
Gracias de antemano. -
@jesus-ul said in En cada linea, ¿cómo eliminar todo lo anterior a la aparición de la primera barra?:
Hello,
I would like to be able to eliminate everything prior to the appearance of the first bar of each line, with the possibility of eliminating the bar or not eliminating it.
Eg: I would
appreciate help.
Sorry if this is an absurd question, I am new to this.
Thanks in advance.In the future, please make postings in English as it is the preferred language of the Community.
Try:
find:
(?-s)^.*?/\h*
replace: nothing
mode: regular expression -
It’s a simple task for RegEx. Open the
Replace
dialog (Ctrl + H) and type:Search: (?-s)^([^/]*? / )(.+?)$ Replace: $2
Put the caret at the very beginning of the document, select the
Regular Expression mode
and click onReplace
orReplace All
.Now, if you want to preserve the first bar, try this other regex, following the above-mentioned instructions:
Search: (?-s)^([^/]*? (?=/ ))(.+?)$ Replace: $2
Notes: Next time, please make postings in English —if inconvenient, translate it with a service like deepl.com . Also, please follow the template for search and replace questions.
Traducción:
Es una tarea sencilla para RegEx. Abre el cuadro de diálogo
Reemplazar
(Ctrl + H) y escribe:Buscar: (?-s)^([^/]*? / )(.+?)$ Reemplazar con: $2
Coloca el signo de intercalación al principio del documento, selecciona el modo “Expresión regular” y haz clic en “Reemplazar” o “Reemplazar todo”.
Ahora bien, si quieres conservar la primera barra, prueba con este otra regex, siguiendo las instrucciones anteriores:
Buscar: (?-s)^([^/]*? (?=/ ))(.+?)$ Reemplazar con: $2
Notas: Te recomiendo que en nuevas publicaciones escribas en inglés, que es el lenguaje de la comunidad -si esto te resulta inconveniente, tradúcelo con un servicio como deepl.com. También recomiendo que utilices la plantilla sobre búsquedas y reemplazos.
-
@astrosofista Hello astrosofista,
thanks for the answer, it’s just what I was looking for, and thanks for your recommendations. I’m new to this community and I don’t know the dynamics of this forum well yet, I’ll do my best.Thanks again. -
@alan-kilborn Hello ,
thanks for the answer, but it is not what I was looking for.
I will explain it more graphically:
thanks again: -
@jesus-ul
You probably did a “replace all”. The regexp is designed to go line for line. Place the caret (cursor) on top of your file and hit “Find Next”. You see a string marked from the start of the first line containing a bar up to the first bar (grey background). You may replace the marked string by “nothing”. If you then hit “Find Next” you will see the first string on the next line marked up to the first bar. You can replace this again by “nothing”, and so on to the end of file. -
@paul-wormer Gracias por la aclaración, es como tu dices,pero tengo ya la solución para reemplazarlo todo de golpe,solución que me la brindo muy amablemente un compañero tuyo,por tanto gracias a todos.
-
@paul-wormer Thanks for the clarification, it is as you say, but I already have the solution to replace it all at once, a solution very kindly provided by a colleague of yours, so thanks to all of you.
-
@jesus-ul said in En cada linea, ¿cómo eliminar todo lo anterior a la aparición de la primera barra?:
thanks for the answer, but it is not what I was looking for.
Ah, my answer fell victim to the “where does the next search start” problem in Notepad++. Most editors would do it with my expression and give you what you wanted. :-(
-
@alan-kilborn thank you very much