Delete part of text by delimiters

Asked

Viewed 170 times

1

Text:

Example [caption id="attachment_90" align="alignleft" width="400"] xxxxxxxxxxxxxxxxx[/caption]

How to exclude any expression above the text.

  • I marked as duplicate pq the solution has already been given in the other, but how @Khaosdoctor can edit the answer given if you want to complement here as well. If any detail is missing in that, leave a comment. Special attention to the 5th code, which seems to me to be what you are looking for.

1 answer

1


You can use regex to remove. If you are using PHP, you can use preg_replace (see on manual) with the following expression: \[.*?\].

Take a look at this example here: https://regex101.com/r/zX6gM2/1

  • Thanks. I want to remove everything, the regex that passed me takes only what is between []. I will study the regex here. Thanks for the help

  • Although you have the duplicate, if you want you can add it to the case @lelopes asked for (there is an example in the link question above, in the answer I gave, if you need it). If you give a shot to get all the content of the caption, you can win some deserved votes, and the lelopes can mark as accepted here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.