$variable = 'of course it is unnecessary [http://google.com],
but it is simple["very simple"], and this simple question clearly
needs a simple, understandable answer [(where is it?)] in plain English'
Value of this variable everytime changes.
What I trying to do is to get the text from [...]
. So, if there is [(google)]
, the match should be (google)
.
I'm searching for a solution, which can do each of these actions:
- get all matches of [...], write into
$all
- get only the first match, write into
$first
- get only the last match, write into
$last
- remove all matches of [...] from the variable (erase)
- remove only first match
- remove only last match
Tried different regex for this, like /[\(.*?\)]/
, but the results aren't what one might expect.
Thanks for your attention, any help would be appreciated.