The optional fourth parameter of preg_replace is limit
:
preg_replace($search, $replace, $subject, 1);
More Related Contents:
- Warning: preg_replace(): Unknown modifier
- Replace preg_replace() e modifier with preg_replace_callback
- Replace URLs in text with HTML links
- php regex to match outside of html tags
- Remove multiple whitespaces
- Convert plain text URLs into HTML hyperlinks in PHP
- Convert string into slug with single-hyphen delimiters only
- PHP remove special character from string
- Replace multiple newlines, tabs, and spaces [duplicate]
- Extract URL from string
- What Delimiter to use for preg_replace in PHP (replace working outside of PHP but not inside)
- Regular expressions for a range of unicode points PHP
- How to remove diacritics from text?
- PHP using preg_replace : “Delimiter must not be alphanumeric or backslash” error
- Unknown modifier ‘/’ error in PHP [duplicate]
- Regex to strip comments and multi-line comments and empty lines
- Replace tabs and spaces with a single space as well as carriage returns and newlines with a single newline
- How to properly escape a backslash to match a literal backslash in single-quoted and double-quoted PHP regex patterns
- regular expression and forward slash
- Regex / DOMDocument – match and replace text not in a link
- PHP Preg-Replace more than one underscore
- Regex ignore URL already in HTML tags
- PHP regular expressions: No ending delimiter ‘^’ found in
- Replacing accented characters php
- Retrieve all hashtags from a tweet in a PHP function
- How to write a recursive regex that matches nested parentheses?
- Using regex to filter attributes in xpath with php
- Regex for password PHP [duplicate]
- How to validate that a string only contain lowercase letters?
- Regular expression: find range except for one letter or a range