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

Search for matches and save and maybe replace it

i'll try to explain my question in the best way i can ... okay. i have a multi line string like this: Hello World And again Hello And again ... Now i want to replace but it depents on what is the first letter, the second and so on. I have…
TJR
  • 6,307
  • 10
  • 38
  • 64
0
votes
2 answers

PHP preg_split with two delimiters and capture only one

Really poor at regular expressions, sorry in advance! I've tried my best to work out how to split a string into a array with two delimiters and still capture one and include it in the final array. preg_split seems ideal for this but my regular…
Jonathon Oates
  • 2,912
  • 3
  • 37
  • 60
0
votes
1 answer

Excluding some pattern from pattern_match in php

I am trying to split raw text into sentences. So I simply use preg_split() function and split a raw text into sentence based on occurrence of ?, . and ;. But as expected I faced some problem due to some special case of . for example "Dr.", "Mr.",…
0
votes
1 answer

preg-split regular expression

I am having the input string of Aspen,Colorado-USA I want to split it by using preg-split I want this output: Array ( [0] => Aspen [1] => Colorado [2] => USA ) I have used like this $input=Aspen,Colorado-USA; $out=preg_split(…
0
votes
1 answer

Grouping and Grep-ing Specific Lines from a variable (PHP)

I have a PHP variable that holds similar data: $var = " Name: Tom Age: 26 Location: London Name: Mike Age: 28 Location: New York Name: Sunny Age: 24 Location: Tokyo"; I'd like to extract only the locations, and store them in Array like: Array ( …
Hasan Alsawadi
  • 394
  • 5
  • 15
0
votes
1 answer

preg_split php function in a php file pattern regexp

Possible Duplicate: Parse PHP code to extract function names? I'm working on a script to read my PHP files and get all the functions as a return. I'm using preg_split() to split my file into an array of functions. I'm having trouble writing the…
0
votes
4 answers

How can I split this array in PHP?

Noob question. I have this: Array ( [0] => address = 123 Something Street [1] => address2 = Something else [2] => city = Kalamazoo [3] => state = MI [4] => zip = 49097 [5] => country = United States ) but I want…
pgtips
  • 1,328
  • 6
  • 24
  • 43
0
votes
2 answers

PHP boolean search

I'm trying to convert a user entered string into a MySQL boolean search. I have the following function which works perfectly for a number of scenarios, however it doesn't work with double quotes. So for example, it WORKS with the following…
0
votes
5 answers

PHP Regexp on filename

I have a collection of files with a certain structure: COMPANY_DE-Actual-Contents-of-File-RGB-ENG.pdf Breakdown: COMPANY -> Company name, fixed DE -> Office location, fixed options: '_DE', '_BE', or absent for non-location-dependent files, if…
knalpiap
  • 67
  • 1
  • 7
0
votes
1 answer

PHP REGEX: Help needed with PREG_SPLIT() for zip code

I have content like San Clemente, CA 92673 or Arlington, TX 76012-3693 And I need to split it into CityAndState and Zip. Some I'm trying: $moreAddressInfo = preg_split('^[0-9.]{5,}^', $row2['cityAndZip'],null,PREG_SPLIT_DELIM_CAPTURE); (also…
mOrloff
  • 2,547
  • 4
  • 29
  • 48
-1
votes
4 answers

php preg_split text

Hopefully a simple problem but cant find the solution anywhere. If I want to take any charactors before the "v" how would I do it? Example: Chelsea v Aston Villa - Match Betting; I cant take the first word as sometimes it is two words like: Man Utd…
user989952
  • 661
  • 1
  • 12
  • 23
-1
votes
1 answer

php first word only from mb string

I used preg_match but its returning pdf as it English that's why may be. But I want to get only 練馬春日町Ⅳ Is there any way to detect it for mb string.
Lemon Kazi
  • 3,308
  • 2
  • 37
  • 67
-1
votes
2 answers

Split String at Last Space before Delimiter Using preg_split?

I'm trying to use preg_split to split the following string at every space before a slash. I know it will be a simple REGEX but I can't seem to figure it out using RegExr? $string = 'DZ9243/XSHAGT FFGD JERSE XS2 DZ9232/MHAGT SUUMTE KNI M10…
lpw
  • 13
  • 4
-1
votes
2 answers

Function Variable - API Response preg_split result and pass created variable to new function

Hoping you can help me here. I am at a bit of a loss :/ I have a function that passes data via API to a server. It sends a response. I need to split the string that comes in and take the final result and make that a variable that can be used by…
-1
votes
1 answer

Regular expression for sentences

My regular expression works well when there is a space after the dot. $str = 'Fry me a Beaver. Fry me a Beaver! Fry me a Beaver? Fry me Beaver no. 4?! Fry me many Beavers... End'; $sentences = preg_split('/(?<=[.?!])\s+(?=[a-z])/i', $str); But I…
Ieeshka
  • 9
  • 4