Questions tagged [preg-split]

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

531 questions
-1
votes
2 answers

PHP Slipt Text and assign to an Array

I am trying to split and assign the values into an array for a text like this: Title: Wonderful World ---- Text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis nulla dui, etiaculis enim porta aliquet. Etiam ante mauris,…
user702300
  • 1,091
  • 3
  • 19
  • 31
-1
votes
3 answers

preg_split regex on different characters

I am trying to split up some titles into 3 parts: Title: Name -- Edition I'd like to split up these strings into Array ( [0] => Title [1] => Name [2] => Edition ) These titles may not have the edition, or the name field, or either of…
Corey
  • 725
  • 1
  • 10
  • 19
-1
votes
2 answers

Splitting GET string

I need to split my GET string into some array. The string looks like this: ident[0]=&value[0]=&version[0]=&....&ident[N]=&value[N]=&version[N]= So, I need to split this string by every third…
-1
votes
2 answers

preg_split for email pattern

$email_address_pattern="([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}"; $address= "abc@gmail.com"; $length=strlen($address); for($position=0;$position<$length;) { …
-1
votes
2 answers

Match words starting with capitals in php?

I have a string $str="NassarWellerGomez-GarciaSanchez-RenedoLoeches-SanchezGomez-GarciaMunoz-FerrerasSanchez-RenedoChiaoHakkarainenWernerValkamaHarounPlett"; I want to match words starting with capitals only like: Nassar Weller Gomez-Garcia etc I…
Aditya
  • 4,368
  • 3
  • 25
  • 38
-1
votes
1 answer

RegExp to get lines with linebreaks

I'm trying to get some comment lines out of our database, they are stored as a string, separated by '\n'. Unfortunately in some of the comments contain texts - also with '\n', and I don't get them separated accordingly. An example comment looks…
manuxi
  • 331
  • 6
  • 11
-2
votes
2 answers

How to parse a mostly consistent filename into meaningful parts?

I have filenames like: 1234_56_78 A_FAIRLY_SHORT_TITLE_D.pdf Luckily, the file naming is pretty consistent, but I can't absolutely guarantee that someone didn't use a space where they should have used an underscore. With this in mind, I want to…
Strawberry
  • 32,714
  • 12
  • 37
  • 56
-2
votes
1 answer

Split/Explode a string in PHP

I need to split or explode a string. K1123-Food, Apple, Z3456-Egg, Mushroom, M9902-Plant, Soil, Water, Q8876-Medicine, Car, Splitter into something like K1123-Food, Apple Z3456-Egg, Mushroom M9902-Plant, Soil, Water Q8876-Medicine, Car,…
davykiash
  • 1,655
  • 5
  • 26
  • 53
-2
votes
6 answers

Regex to split string into array of numbers and characters using PHP

I have an arithmetic string that will be similar to the following pattern. a. 1+2+3 b. 2/1*100 c. 1+2+3/3*100 d. (1*2)/(3*4)*100 Points to note are that 1. the string will never contain spaces. 2. the string will always be a…
-2
votes
2 answers

How to split string into an alphabetic string and a numeric string?

I need to use preg_split() function to split string into alpha and numeric. Ex: ABC10000 into, ABC and 10000 GSQ39800 into GSQ and 39800 WERTYI67888 into WERTYI and 67888 Alpha characters will be the first characters(any number of) of the string…
Shaolin
  • 2,451
  • 4
  • 27
  • 37
-2
votes
2 answers

PHP split string on word before colon

I have a string that looks like this: aaaaa: lorem ipsum bb: dolor sit amet ccc: no pro movet What would be the best way to split the string into an array and get the following result in PHP? array[0]='aaaaa: lorem ipsum'; array[1]='bb: dolor sit…
johnohod
  • 406
  • 5
  • 17
-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]…
-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
  • 93
  • 1
  • 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,368
  • 3
  • 25
  • 38
-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
  • 47
  • 1
  • 1
  • 6
1 2 3
35
36