For example i have string one two three four five and I want remove all characters before two and after four , I know that is function preg_replace() but I don’t know how to write this expression, I not know what does mean for example ‘/([a-z])([A-Z])/’ please say what is name of this expression in $pattern and what they mean
For example i have string one two three four five and I want remove
Share
In case you’re looking for preg_replace based solution then here it is:
Expanation: RegEx used in
preg_replacefirst matches text upto your starting texttwothen matches upto your end textfourand finally replaces it with matched string thus discarding all text beforetwoand all text afterfour. Please note.*?makes your matching non-greedy. Read more about regex here: http://www.regular-expressions.info/OUTPUT