obtener una parte de una cadena con Bash
Linux/Unix Shell Scripting
Publicado el 19 de Marzo del 2021 por Xavi (548 códigos)
923 visualizaciones desde el 19 de Marzo del 2021
Código que muestra como obtener parte de una cadena en bash
firstStringBetween('This is a [custom] string', '[', ']'); // "custom"
firstStringBetween('This is a #custom# string', '#', '#'); // "custom"
firstStringBetween('This is a "custom" string', '"', '"'); // "custom"
firstStringBetween('This is a custom string', 'is a', 'string'); // "custom"
firstStringBetween('This is a custom string', 'This', 'a'); # "is"
firstStringBetween('This is a [custom string', '[', ']'); // ""
firstStringBetween('This is a [custom] string', '', ''); // ""
firstStringBetween('This is a custom string', '*', '*'); // ""
firstStringBetween('This is a [custom] string', '[', ']') # "custom"
firstStringBetween('This is a #custom# string', '#', '#') # "custom"
firstStringBetween('This is a "custom" string', '"', '"') # "custom"
firstStringBetween('This is a custom string', 'is a', 'string') # "custom"
firstStringBetween('This is a custom string', 'This', 'a') # "is"
firstStringBetween('This is a [custom string', '[', ']') # ""
firstStringBetween('This is a [custom] string', '', '') # ""
firstStringBetween('This is a custom string', '*', '*') # ""