preg_split() is a PHP function which allows splitting a string using a regular expression.
Questions tagged [preg-split]
531 questions
-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…
![](../../users/profiles/4198180.webp)
Ankit Jindal
- 1,950
- 2
- 15
- 26
-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…
![](../../users/profiles/1512593.webp)
user1512593
- 361
- 3
- 6
- 15
-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…
![](../../users/profiles/7668554.webp)
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+(?[ⴰ-⵿…
![](../../users/profiles/232082.webp)
numediaweb
- 13,837
- 11
- 59
- 100
-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:
![](../../users/profiles/1451083.webp)
JohnSmith
- 407
- 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] =>…
![](../../users/profiles/5119026.webp)
Jack
- 81
- 7