I have a JavaScript application where I need to manipulate strings.
The text follows this structure:
- It might begin with a prefix in square brackets [prefix]. I have to preserve this prefix with the brackets.
- Next comes [whatever string], in this case I only need the text within the brackets.
For example:
[prefix][My title]
Returns: [prefix] My title
For example:
[Another title without prefix]
Returns: Another title without prefix