preg_split() is a PHP function which allows splitting a string using a regular expression.
Questions tagged [preg-split]
550 questions
-2
votes
2 answers
preg_split with last 2-3 characters non alphanumerical
So I'm working on some php, and looking for some help with regular exp.
I have an array of string looking like this:
$variable_with_strings
array(
[0][art] => >AngusDelu -
[1][art] => >PatatasJr -
[2][art] => >AngusHabane *
[3][art]…

Daniel Clarks
- 15
- 8
-2
votes
2 answers
function split() deprecated - besides preg_split what else needs to be changed in this code? general idea
I know that there are several questions about this issue, but this is a particullar case...
In the following code (in the the first and the last line) I have to replace split with preg_split, but I think something else needs to be changed…

Klauss Gekker
- 143
- 2
- 8
-2
votes
2 answers
Splitting string array based upon digits in php?
I have a string
$str = "101WE3P-1An Electrically-Small104TU5A-3,Signal-Interference Duplexers Gomez-GarciaRobertoTU5A-3-01"
I want to split this string by the numbers, eg:"101WE3P-1An.... "should be first element, "104TUA..." should be second…

Aditya
- 4,453
- 3
- 28
- 39
-2
votes
1 answer
preg_split() 2 letters and decimal
I have a string and this string should be an array.
But the first 2 letters are variable and I need the 5 next digits (whether empty or not). The last 5 digits are numeric with a decimal point or empty ( $string="AB3 . ";)
An example:
$string =…

JasperM
- 57
- 1
- 1
- 6
-3
votes
2 answers
What would be regular expression to split following string in php?
string
T1 - X1(1), 7
T2 - C2(-9), -15
T3 - Y2(1), 3
T5 - C2(-1), 100
regexp used for preg_split
$pattern = "/[-,#\n#()]/";
preg_split($pattern, $string);
In above regular expression it is considering the hyphen space same as minus in front of a…

Ankit Jindal
- 3,672
- 3
- 25
- 37
-3
votes
2 answers
PHP Regex Multiple Instances
I'm currently importing CSV data and need to get it all nice and arrayed out.
Smaller Example Data is as follows.
"Name","Address"
"John Doe","5111 Fury Rd
Santa Cruz"
"Jane Doe","321 Tess St Texas"
"Josh Doe","653 1st St
Orlando Florida
United…

user1512593
- 381
- 3
- 6
- 16
-3
votes
1 answer
Extract different patterns of lat long date time float from 1 string and split it to variables
I need a regex expert who can split this single string variable into multiple variables. Coming data from source having line break but not showing \n.
I will be very thankful.
$text_utf8_test = "lat:24.910717 lon:67.073710
speed:0.00
T:17/02/22…

Aadeelyoo
- 15
- 5
-3
votes
1 answer
Split a complex string with a preg_split
Update v2
Using the code by Jerry works on most strings, but not all of them, like:
$pattern = '#^(?(?:\([^)]+\)|[^-]+)+)\s+-\s+(?[^:]+)\s+:\s+(?[^/]+)\s+/\s+(?[^/]+)\s+/\s+(?\S+)\s+(?[ⴰ-⵿…

numediaweb
- 16,362
- 12
- 74
- 110
-3
votes
1 answer
Regular expression li and a
Possible Duplicate:
How to parse and process HTML with PHP?
Im trying to figure out how to get the word/words in the -tagg by regular expression. My content is this:

JohnSmith
- 417
- 4
- 10
- 21
-4
votes
1 answer
splitting string into php array
I have an array that outputs the following:
Array
(
[0] => #EXTM3U
[1] => #EXTINF:206,"Weird" Al Yankovic - Dare to be Stupid
[2] => E:\Dare to be Stupid.mp3
[3] => #EXTINF:156,1910 Fruitgum Company - Chewy, Chewy
[4] =>…

Jack
- 91
- 7