I have been trying to make a regular expression in javascript to get the text between 2 brackets for example
[descripcion] Esta es una descripcion [/descripcion]
Which should return "This is a description"
I have been testing with this(\Q[descripcion]\E)(\X*)(\Q[/descripcion]\E)
But nothing at all, can someone help me with the expression ?
Another thing, the full text without filtering is like this
[descripcion] La Descripcion [/descripcion][ingredientes] Los ingredientes [/ingredientes][sabor] Sabor [/sabor][aroma] Aroma [/aroma][tiempo]3-5 min[/tiempo][temperatura]80°[/temperatura][cantidad]2,5g/250ml[/cantidad][preparacion] Preparacion [/preparacion][pais]China[/pais][contenido][/contenido][modouso][/modouso]
I just want what's inside[descripcion] esto [/descripcion]
Many thanks
You can define an expression like this:
The slashes are to escape the square brackets since they are reserved characters and the parentheses are used to create groups. In this case we create a group with everything that is written between [description][/description].
To obtain the content of the groups we use exec, with which you will obtain an array with the groups found. In position 0 of the array will be the text that you have passed as a parameter, in position 1 group 1, in position 2 group 2, etc.
you can do it like this: