Questions tagged [preg-split]

preg_split() is a PHP function which allows splitting a string using a regular expression.

550 questions
0
votes
2 answers

Split long text into paragraphs on EOL and

tags

I need to split a long text into paragraphs in order to do some manipulation. The goals: Split long text into paragraphs based on any combination of newline characters,

, and

(any combination of id, class, or…

TonyaGM
  • 65
  • 7
0
votes
1 answer

Preg Split ignore case

I'm trying to ignore uppercase or lowercase with the code below to detect whether the user is blocked or not. Is working when matching the username or email but with the case problem, the validation does not work. How to make it case insensitive?…
Samual99
  • 15
  • 5
0
votes
1 answer

preg_split regex doesn't work right

Have to split a text by an dynamic id f.e. My regex: $content = preg_split('/<\/span>/i', get_the_content('more')); Unfortunately sometimes it works, sometimes not: -> it works
Stiller Eugen
  • 681
  • 2
  • 10
  • 28
0
votes
2 answers

How to split a string into an array using a given regex expression

I am trying to explode / preg_split a string so that I get an array of all the values that are enclosed in ( ). I've tried the following code but I always get an empty array, I have tried many things but I cant seem to do it right Could anyone spot…
Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78
0
votes
1 answer

Apache Connection Reset with preg_split

I'm facing a very weird behavior with Apache/2.2.25 (Win32) and PHP/5.4.10, I have this code $content = << >
0
votes
2 answers

PHP Parsing text to extract two numbers

The text is similar to this: +1191–1405 Holy Damage The numbers can change as well as the Damage type. Like +777-1444 Fire Damage ect. What I want to do is extract the two numbers. So from the first example I want 1191 and 1405 and I need them to…
Paul Duncan
  • 302
  • 1
  • 5
  • 19
0
votes
0 answers

preg_split for both a space and a forward slash

I am trying to basically explode a string with both a space and a forward slash. This is what I have: $array = preg_split("/[\s,\/]+/", $string) But I think I am doing something wrong. I have searched online but I can't really grasp how you enclose…
user2961763
  • 63
  • 1
  • 9
0
votes
1 answer

Ignore if specific character matched

I have a string: $str = "yellow;yellow\;er;yellowest"; And I use preg_split like this: preg_split("/;/", $str); But I want to get results like this: array( "yellow", "yellow;er", "yellowest" ) But the results is not right. So actually…
0
votes
1 answer

PHP preg_split for Breaking Up Long References

I've been trying to create a regular expression to split up a variety of scripture references. Here's what I've got so far: $split_references = preg_split("/((, | or | and ))[^0-9(]/i", $reference); A sample of text that this may need to deal with…
Jason Silver
  • 527
  • 7
  • 23
0
votes
4 answers

Split datetime string into its individual components without using a datetime function/method

I have a string $string = "2012-1-12 51:00:00.5"; How can I explode this date into year, month, day, hour, minutes, seconds without using a date function. I was trying with multiple calls of explode() because it can only split on one delimiter at a…
jsduniya
  • 2,464
  • 7
  • 30
  • 45
0
votes
2 answers

How to spilt out parts of a string

I have a coordinate in the format 43-09-42.0000N I want to split it into its component parts 43 09 42.000 N I'm using. $parts = preg_split('/[-]/', $LON); and it gives me Array ( [0] => 43 [1] => 09 [2] => 42.0000N ) But I can't figure out who…
MB.
  • 723
  • 1
  • 11
  • 28
0
votes
1 answer

How to use preg_split to split string at whitespace between numbers?

I have been trying to create a regex expression which only selects the whitespace between numbers, which preg_split can split. For example: $string = "Unit 54 981 Mayne Street"; Would return as: array() { [0]=> "Unit 54" [1]=> "981 Mayne…
Sam-
  • 28
  • 5
0
votes
3 answers

php preg_split by semi-colons not found between opening and closing brackets

I'm writing a recursive function and I'm getting into trouble on the regular expression part... hopefully one of you kind people can help... give a single string with contents such as…
user3168961
  • 375
  • 1
  • 10
0
votes
5 answers

php split string using date format

I have a simple string that should contain a name and a date of birth as below: $searchParams = '12/12/1978 Bob Smithers'; or alternatively $searchParams = 'Bob Smithers 12/12/1978'; What I need to do is split the date away from the name if the…
Sideshow
  • 1,321
  • 6
  • 28
  • 50
0
votes
1 answer

split combined words with preg_split function

I need your help in my code: $sentence = "Erzurum da hayat çok monoton SANIRIM:d"; $words = preg_split('/[\s,.\'\-\[\]]+/', $sentence, -1, PREG_SPLIT_NO_EMPTY); this code splits the sentence into words and the output is below Array ( [Erzurum] =>…
gocen
  • 103
  • 1
  • 10