Estoy tratando de seleccionar subcadenas marcadas entre banderas (usando % como banderas). También debe evitar secciones marcadas entre otra bandera (usando & para la segunda bandera).
&Label 1&%A lot of text goes in here, but this is the part I want to pick out as a match, it needs to include characters such as __**underline and asterisk**__ and also be able to handle \n line breaks.%&Label 2&%This would become the second match. We also want to include symbols such as 🍗 and other emotes.%
Quiero que esto resulte en dos coincidencias:
A lot of text goes in here, but this is the part I want to pick out as a match, it needs to include characters such as __**underline and asterisk**__ and also be able to handle \n line breaks.This would become the second match. We also want to include symbols such as 🍗 and other emotes.He intentado:
/(?<=%)[^&].*?(?=%)/g <- Funciona en https://regex101.com/ pero no en mi propio script java
getFieldLabels: function(text){ let regexp = /(?<=&)[a-zA-Z\s]*(?=&)/g; let array = [...text.matchAll(regexp)]; return array; }, /(%(.*)\%)/g <- Requiere un salto de fila en la cadena para funcionar