marc
marc

Reputation: 827

preg_match expression for extracting everything but "[]"

<some string>[]<somestring>

example

variable[]_abc

How can I get everything except [] from the string using preg_ in php?

Upvotes: 0

Views: 28

Answers (2)

chris85
chris85

Reputation: 23880

If you only want to remove [] use str_replace.

$newstring = str_replace('[]', '' $string);

There is no need for a regex to remove static characters.

Upvotes: 1

Lakremon
Lakremon

Reputation: 807

preg_replace('/\[\]/','',$string);

Upvotes: 1

Related Questions