Hola, tengo este archivo JSON. Quiero eliminar las llaves del interior de las cadenas en la matriz de capítulos, pero si estas llaves contienen más de 3 palabras (2 espacios dentro de las llaves), quiero que se elimine la llave completa. . ¿Es posible con la expresión regular ?
{ "abbrev": "gn", "name": "Genesis", "chapters": [ [ "And the earth was without form, and void; and darkness {was} upon the face of the deep. And the Spirit of God moved upon the face of the waters.", "And God said, Let there be light: and there was light.", "And God saw the light, that {it was} good: and God divided the light from the darkness. {the light from...: Heb. between the light and between the darkness}", "And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. {And the evening...: Heb. And the evening was, and the morning was etc.}", "And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters. {firmament: Heb. expansion}" ] ] }Intenté resolver con una mirada negativa al futuro, resultados insatisfactorios. Y si no es posible con la expresión regular, ¿cuál sería la solución en javascript?
No veo por qué no pudiste resolver esto usando 2 expresiones regulares:
var regex1 = /{[^{}]+[ ][^{}]+[ ][^{}]+}/g; var regex2 = /[{}]/g; var str = ...; str = str.replace(regex1, ""); str = str.replace(regex2, "");