Estoy luchando por encontrar un patrón Regex para JavaScript que recortará una ruta de sus barras inclinadas anteriores y posteriores (o hashes/extensiones)
Por ejemplo:
path/ /path /folder/path/ /folder/folder/path /folder/path#hash /folder/path.extDebería volver:
path path folder/path folder/folder/path folder/path folder/pathSentí que me estaba acercando a lo siguiente, pero solo selecciona texto sin barras, hash o puntos.
^([^\\\/\#\.]*)(?![\#\.\\\/].*$)/gmEstoy tratando de usar esto para Regex en una validación de campo de texto vuetify, si eso es útil.
Terminé con esta babosa de expresiones regulares
/^(?![\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s])(?!.*[\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]$)[^\#\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]*$/Así es como se logra sin mirar atrás (siguen siendo rechazados en Safari :():
^(?![#\/.])(?!.*[#\/.]$).*Ver prueba de expresiones regulares . Y...
EXPLICACIÓN
-------------------------------------------------------------------------------- ^ the beginning of the string -------------------------------------------------------------------------------- (?! look ahead to see if there is not: -------------------------------------------------------------------------------- [#\/.] any character of: '#', '\/', '.' -------------------------------------------------------------------------------- ) end of look-ahead -------------------------------------------------------------------------------- (?! look ahead to see if there is not: -------------------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) -------------------------------------------------------------------------------- [#\/.] any character of: '#', '\/', '.' -------------------------------------------------------------------------------- $ before an optional \n, and the end of the string -------------------------------------------------------------------------------- ) end of look-ahead -------------------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))Utilice una mirada hacia delante negativa al principio y una mirada hacia atrás negativa al final.
/^(?![#\/.]).*(?<![#\/.])$/