Skip to content
Advertisement

Tag: split

How to split text based on specific word

I have a text which contains the word “Article” many times for example: My text title Article 1 bla bla Article 2 bla bla … I want to split the text like this: Answer Instead of trying to find a split pattern, you should look for a matching pattern: It matches Article, followed by anything up to but not including

Split string on non-alphanumeric characters and on positions between digits and non-digits

I’m trying to split a string by non-alphanumeric delimiting characters AND between alternations of digits and non-digits. The end result should be a flat array of consisting of alphabetic strings and numeric strings. I’m working in PHP, and would like to use REGEX. Examples: ES-3810/24MX should become [‘ES’, ‘3810’, ’24’, ‘MX’] CISCO1538M should become [‘CISCO’ , ‘1538’, ‘M’] The input

“Function split() is deprecated” in PHP?

Deprecated: Function split() is deprecated in C:wampwwwRSS.php on line 27 Why this error happen ? Answer http://php.net/manual/en/function.split.php From the manual Warning This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED

Split a string array into pieces

Let’s say I have an array that store like this: How should I make the array[0] string split into piece by separated the “;”? Then I want to save them in array again, or display them out. How should I do it? Answer I would personally use the preg_split to get rid of that extra array element that would occur

Explode string only once on first occurring substring

preg_match() gives one match. preg_match_all() returns all matches. preg_split() returns all splits. How can I split only on the first match? Example: This is what I want: Answer Simply set $limit to 2 for 2 parts of the array. Thanks to @BenJames for mentioning: I tested and it works fine. The limit argument: If specified, then only substrings up to

Advertisement